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,终于对上了。
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://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。
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 commentVersion = 2.1.2.4000,有空了再细看。
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.