google map的projection

September 26, 2010 at 1:03 am | Posted in Uncategorized | Leave a comment

想把GMap.Net和SharpMap合在一起,发现坐标系对不上,总是有点误差。仔细google,发现http://www.sharpgis.net/post/2007/07/27/The-Microsoft-Live-Maps-and-Google-Maps-projection.aspx, 自己Create Transform,终于对上了。

IronPython, 中文

August 6, 2010 at 2:51 am | Posted in Uncategorized | Leave a comment

cross-domain in Silverlight on self-hosted WCF services

August 4, 2010 at 4:18 am | Posted in Uncategorized | Leave a comment

在Silverlight中调用WCF服务(不在IIS中,而是自己开了个ServiceHost),总是出现System.Security.SecurityException。网上看看基本上是说加2个文件crossdomain.xml,clientaccesspolicy.xml。但因为不Host在IIS中,所以。。。应该。。。,请看

http://blogs.msdn.com/b/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx

http://wallism.wordpress.com/2009/03/01/silverlight-communication-exception/

在WinForm程序中开启Console

April 26, 2010 at 5:29 am | Posted in Uncategorized | 1 Comment

在程序中用到了IronPython,然后想到是否可以在程序中开启一个Console窗口用于调试,就像ipy.exe一样,只不过需要传入当前程序的一些变量。

用Reflector查看ipy.exe代码,复制了一个PythonConsoleHost.cs到自身代码,然后需要AllocConsole()开启Console窗口(FreeConsole关闭),因为PythonConsoleHost.Run直到Console关闭才返回,所以需要在另外一个进程中Run PythonConsoleHost。

有个小问题,关于Console.Output(Error, Input)的。因为程序中另外用到了PythonEngine,其中又调用了Console的标准输入输出,导致新开的PythonConsoleHost输出出现问题,因此需要host.Runtime.IO.SetOutput(System.Console.OpenStandardOutput(), System.Console.OutputEncoding);

Windows-Communication-Foundation-Unleashed Notes

April 16, 2010 at 5:19 am | Posted in Uncategorized | Leave a comment

很一般的一本书,泛泛介绍了一下WCF,很多可以不用看。
1.    Service Configuration Editor 可用于可视化编辑配置文件
2.    Windows Communication Foundation Predefined Bindings
a)    BasicHttpBinding    : Maximum interoperability through conformity to the WS-BasicProfile 1.1
b)    WSHttpBinding        : HTTP communication in conformity with WS-* protocols
c)    WSDualHttpBinding    : Duplex HTTP communication, by which the receiver of an initial message will not reply directly to the initial sender, but may transmit any number of responses over a period
d)    WSFederationBinding     : HTTP communication, in which access to the resources of a service can be controlled based on credentials issued by an explicitly identified credential provider
e)    NetTcpBinding        : Secure, reliable, high-performance communication between Windows Communication Foundation software entities across a network
f)    NetNamedPipeBinding    : Secure, reliable, high-performance communication between Windows Communication Foundation software entities on the same machine
g)    NetMsmqBinding        : Communication between Windows Communication Foundation software entities via Microsoft Message Queuing (MSMQ)
h)    MsmqIntegrationBinding    : Communication between a Windows Communication Foundation software entity and another software entity via MSMQ
i)    NetPeerTcpBinding    : Communication between Windows Communication Foundation software entities via Windows Peer-to-Peer Networking
3.    Serialization: System.ServiceModel.ServiceKnownType; IExtensibleDataObject , ExtensionDataObject
4.    Exception: FaultContract, FaultException; IncludeExceptionDetailInFaults in System.ServiceModel.Description.ServiceDebugBehavior
5.    reliableSession:  <reliableSession enabled=”true” ordered=”true” />. WSHttpBinding, the WSDualHttpBinding, the WSFederationBinding, the NetTcpBinding, and the NetNamedPipesBinding., [DeliveryRequirements(RequireOrderedDelivery = true)]
6.    session management: [ServiceContract(SessionMode=SessionMode.Required)], [OperationContract(IsInitiating=true)], [OperationContract(IsTerminating=true)]
7.    Queued Delivery: Microsoft Message Queuing MSMQ, [DeliveryRequirements(QueuedDeliveryRequirements = QueuedDeliveryRequirementsMode.Required)]
8.    Transactions: [OperationContract(IsOneWay = false)] [TransactionFlow(TransactionFlowOption.Required)], [OperationBehavior(TransactionScopeRequired=true)]; OperationContext.Current.SetTransactionComplete();compensationClient
9.    Security: Transport Security and Message Security; ServiceSecurityContext
10.    Channel Layer: authentication; Service Model layer: authorization and the impersonation
11.    custom behavior, Custom Channels, Custom Transports
12.    Publist and subscribe
13.    Management:
a)    Configuration         : System New Windows Communication Foundation Service Configuration Editor
b)    Security Event Logging     : Familiar Windows Event Viewer
c)    Message Logging     : New Windows Communication Foundation Service Trace View
d)    Activity Tracing     : New Windows Communication Foundation Service Trace View
e)    Performance Counters     : Familiar Windows Performance Monitor
f)    WMI Provider         : Many familiar tools including WMI CIM Studio, ScriptOMatic, and Windows PowerShell

ASP.NET Encoding in QueryString

April 15, 2010 at 3:56 am | Posted in Uncategorized | Leave a comment

编码总是一个麻烦的事情。ASP.NET中默认用UTF8, 但FireFox中QueryString用的是gb2312,所以需要在about:config中更改 network.standard-url.encode-query-utf8为true。

About NHibernate EntityMode

April 14, 2010 at 11:52 am | Posted in Uncategorized | Leave a comment

WCF, REST, SOAP….

April 13, 2010 at 1:53 am | Posted in Uncategorized | Leave a comment

NHibernate的Proxy如何用Cache

April 1, 2010 at 6:44 am | Posted in Uncategorized | 1 Comment

目的:系统中有些数据不大会变化,例如人员信息,但又不想EagerLoad,想采用系统内缓存数据。如何控制Proxy的动作?

方法:1. 继承一个IProxyFactoryFactory,生成自定义的IProxyFactory。

public class ProxyFactoryFactory : IProxyFactoryFactory
    {
        public IProxyFactory BuildProxyFactory()
        {
            return new ProxyFactory();
        }

        public IProxyValidator ProxyValidator
        {
            get
            {
                return new DynProxyTypeValidator();
            }
        }
    }

2. 写自定义IProxyFactory

public class ProxyFactory : AbstractProxyFactory
   {
       private static readonly LinFu.DynamicProxy.ProxyFactory factory = new LinFu.DynamicProxy.ProxyFactory();
       protected static readonly ILog log = LogManager.GetLogger(typeof(NHibernate.ByteCode.LinFu.ProxyFactory));

       public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
       {
           INHibernateProxy proxy;
           try
           {
               NHibernate.ByteCode.LinFu.LazyInitializer interceptor = new NHibernate.ByteCode.LinFu.LazyInitializer(this.EntityName, this.PersistentClass, id, this.GetIdentifierMethod, this.SetIdentifierMethod, this.ComponentIdType, session);
               object obj2 = base.IsClassProxy ? factory.CreateProxy(this.PersistentClass, interceptor, this.Interfaces) : factory.CreateProxy(this.Interfaces[0], interceptor, this.Interfaces);
               proxy = (INHibernateProxy)obj2;

               object target = TryGetCachedTarget(this.PersistentClass, id);
               if (target != null)
               {
                   interceptor.SetImplementation(target);
               }
           }
           catch (Exception exception)
           {
               log.Error("Creating a proxy instance failed", exception);
               throw new HibernateException("Creating a proxy instance failed", exception);
           }
           return proxy;
       }

       private object TryGetCachedTarget(Type persistentClass, object id)
       {
           //return buffered entity
       }
   }

这里采用LinFu的LazyInitializer,首先尝试读系统缓存,如果没用,用原有LazyInitializer,如果有,则用缓存内内容,然后设置好LazyInitializer的target。

NHibernate 默认DynamicUpdate = True了?

April 1, 2010 at 2:35 am | Posted in Uncategorized | Leave a comment

Version = 2.1.2.4000,有空了再细看。

Next Page »

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

Follow

Get every new post delivered to your Inbox.