本文整理汇总了C#中System.Runtime.Remoting.Contexts.Context.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Freeze方法的具体用法?C# Context.Freeze怎么用?C# Context.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Remoting.Contexts.Context
的用法示例。
在下文中一共展示了Context.Freeze方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProviderValidationProxy
public ProviderValidationProxy(Type type, Type connectionType, bool schemaNameSupported)
: base(type)
{
context = new Context();
context.Freeze();
this.connectionType = connectionType;
this.schemaNameSupported = schemaNameSupported;
}
示例2: CreateNewContext
internal static Context CreateNewContext (IConstructionCallMessage msg)
{
// Create the new context
Context newContext = new Context();
foreach (IContextProperty prop in msg.ContextProperties)
{
if (newContext.GetProperty (prop.Name) == null)
newContext.SetProperty (prop);
}
newContext.Freeze();
// Ask each context property whether the new context is OK
foreach (IContextProperty prop in msg.ContextProperties)
if (!prop.IsNewContextOK (newContext))
throw new RemotingException("A context property did not approve the candidate context for activating the object");
return newContext;
}
示例3: DoCrossContextActivation
[System.Security.SecurityCritical] // auto-generated
internal static IConstructionReturnMessage DoCrossContextActivation(
IConstructionCallMessage reqMsg)
{
bool bCtxBound = reqMsg.ActivationType.IsContextful;
Context serverContext = null;
if (bCtxBound)
{
// If the type is context bound, we need to create
// the appropriate context and activate the object inside
// it.
// <
// Create a new Context
serverContext = new Context();
// <
ArrayList list = (ArrayList) reqMsg.ContextProperties;
RuntimeAssembly asm = null;
for (int i=0; i<list.Count; i++)
{
IContextProperty prop = list[i] as IContextProperty;
if (null == prop)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Activation_BadAttribute"));
}
asm = (RuntimeAssembly)prop.GetType().Assembly;
// Make a security check to ensure that the context property
// is from a trusted assembly!
CheckForInfrastructurePermission(asm);
// This ensures that we don't try to add duplicate
// attributes (eg. type attributes common on both client
// and server end)
if (serverContext.GetProperty(prop.Name) == null)
{
serverContext.SetProperty(prop);
}
}
// No more property changes to the server context from here.
serverContext.Freeze();
// (This seems like an overkill but that is how it is spec-ed)
// Ask each of the properties in the context we formed from
// if it is happy with the current context.
for (int i=0; i<list.Count;i++)
{
if (!((IContextProperty)list[i]).IsNewContextOK(
serverContext))
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Activation_PropertyUnhappy"));
}
}
}
IConstructionReturnMessage replyMsg;
InternalCrossContextDelegate xctxDel =
new InternalCrossContextDelegate(DoCrossContextActivationCallback);
Object[] args = new Object[] { reqMsg };
if (bCtxBound)
{
replyMsg = Thread.CurrentThread.InternalCrossContextCallback(
serverContext, xctxDel, args) as IConstructionReturnMessage;
}
else
{
replyMsg = xctxDel(args) as IConstructionReturnMessage;
}
return replyMsg;
}
示例4: DoCrossContextActivation
// This function is called by ActivationServices in case
// the activation needs to be within the same appdomain. These
// are only for ContextBound types.
// It is also called to do satisfy remote incoming requests from
// the activation services. These could be for both ContextBound
// and MarshalByRef types.
internal static IConstructionReturnMessage DoCrossContextActivation(
IConstructionCallMessage reqMsg)
{
bool bCtxBound = reqMsg.ActivationType.IsContextful;
ContextTransitionFrame frame = new ContextTransitionFrame();
if (bCtxBound)
{
// If the type is context bound, we need to create
// the appropriate context and activate the object inside
// it.
// Create a new Context
Context serverContext = new Context();
ArrayList list = (ArrayList) reqMsg.ContextProperties;
Assembly asm = null;
for (int i=0; i<list.Count; i++)
{
IContextProperty prop = list[i] as IContextProperty;
if (null == prop)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Activation_BadAttribute"));
}
asm = prop.GetType().Assembly;
// Make a security check to ensure that the context property
// is from a trusted assembly!
CheckForInfrastructurePermission(asm);
// This ensures that we don't try to add duplicate
// attributes (eg. type attributes common on both client
// and server end)
if (serverContext.GetProperty(prop.Name) == null)
{
serverContext.SetProperty(prop);
}
}
// No more property changes to the server context from here.
serverContext.Freeze();
// (This seems like an overkill but that is how it is spec-ed)
// Ask each of the properties in the context we formed from
// if it is happy with the current context.
for (int i=0; i<list.Count;i++)
{
if (!((IContextProperty)list[i]).IsNewContextOK(
serverContext))
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Activation_PropertyUnhappy"));
}
}
// Change to server context
Thread.CurrentThread.EnterContext(serverContext, ref frame);
}
// call the first sink in the server context chain
IMethodReturnMessage retMsg = (IMethodReturnMessage)
Thread.CurrentContext.GetServerContextChain().SyncProcessMessage(reqMsg);
// The return message may not be of type
// IConstructionReturnMessage if an exception happens
// in the sink chains.
Exception e = null;
IConstructionReturnMessage replyMsg = retMsg as IConstructionReturnMessage;
if (null == replyMsg)
{
if (retMsg != null)
{
e = retMsg.Exception;
}
else
{
e = new RemotingException(
Environment.GetResourceString(
"Remoting_Activation_Failed"));
}
replyMsg = new ConstructorReturnMessage(e,null);
// We have created our own message ... transfer the callcontext
// from the request message.
((ConstructorReturnMessage)replyMsg).SetLogicalCallContext(
(LogicalCallContext)
reqMsg.Properties[Message.CallContextKey]);
}
if (bCtxBound)
{
Thread.CurrentThread.ReturnToContext(ref frame);
}
//.........这里部分代码省略.........
示例5: DoCrossContextActivation
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg)
{
bool isContextful = reqMsg.ActivationType.IsContextful;
Context newCtx = null;
if (isContextful)
{
newCtx = new Context();
ArrayList contextProperties = (ArrayList) reqMsg.ContextProperties;
RuntimeAssembly asm = null;
for (int i = 0; i < contextProperties.Count; i++)
{
IContextProperty prop = contextProperties[i] as IContextProperty;
if (prop == null)
{
throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute"));
}
asm = (RuntimeAssembly) prop.GetType().Assembly;
CheckForInfrastructurePermission(asm);
if (newCtx.GetProperty(prop.Name) == null)
{
newCtx.SetProperty(prop);
}
}
newCtx.Freeze();
for (int j = 0; j < contextProperties.Count; j++)
{
if (!((IContextProperty) contextProperties[j]).IsNewContextOK(newCtx))
{
throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy"));
}
}
}
InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback);
object[] args = new object[] { reqMsg };
if (isContextful)
{
return (Thread.CurrentThread.InternalCrossContextCallback(newCtx, ftnToCall, args) as IConstructionReturnMessage);
}
return (ftnToCall(args) as IConstructionReturnMessage);
}