本文整理汇总了C#中IDesignerSerializationManager.SetName方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerSerializationManager.SetName方法的具体用法?C# IDesignerSerializationManager.SetName怎么用?C# IDesignerSerializationManager.SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDesignerSerializationManager
的用法示例。
在下文中一共展示了IDesignerSerializationManager.SetName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateResourceManager
private SerializationResourceManager CreateResourceManager(IDesignerSerializationManager manager)
{
SerializationResourceManager resourceManager = this.GetResourceManager(manager);
if (!resourceManager.DeclarationAdded)
{
resourceManager.DeclarationAdded = true;
manager.SetName(resourceManager, this.ResourceManagerName);
}
return resourceManager;
}
示例2: DeserializeInstance
protected override object DeserializeInstance(IDesignerSerializationManager manager, Type type, object[] parameters, string name, bool addToContainer)
{
if (typeof(IContainer).IsAssignableFrom(type))
{
object service = manager.GetService(typeof(IContainer));
if (service != null)
{
manager.SetName(service, name);
return service;
}
}
return base.DeserializeInstance(manager, type, parameters, name, addToContainer);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:ContainerCodeDomSerializer.cs
示例3: DeserializeAssignmentStatement
private void DeserializeAssignmentStatement (IDesignerSerializationManager manager, CodeAssignStatement statement)
{
CodeExpression leftExpr = statement.Left;
// Assign to a Property
//
CodePropertyReferenceExpression propRef = leftExpr as CodePropertyReferenceExpression;
if (propRef != null) {
object propertyHolder = DeserializeExpression (manager, null, propRef.TargetObject);
object value = null;
if (propertyHolder != null && propertyHolder != _errorMarker)
value = DeserializeExpression (manager, null, statement.Right);
if (value != null && value != _errorMarker && propertyHolder != null) {
PropertyDescriptor property = TypeDescriptor.GetProperties (propertyHolder)[propRef.PropertyName];
if (property != null) {
property.SetValue (propertyHolder, value);
} else {
ReportError (manager,
"Missing property '" + propRef.PropertyName +
"' in type '" + propertyHolder.GetType ().Name + "'");
}
}
}
// Assign to a Field
//
CodeFieldReferenceExpression fieldRef = leftExpr as CodeFieldReferenceExpression;
if (fieldRef != null && fieldRef.FieldName != null) {
// Note that if the Right expression is a CodeCreationExpression the component will be created in this call
//
object fieldHolder = DeserializeExpression (manager, null, fieldRef.TargetObject);
object value = null;
if (fieldHolder != null && fieldHolder != _errorMarker)
value = DeserializeExpression (manager, fieldRef.FieldName, statement.Right);
FieldInfo field = null;
RootContext context = manager.Context[typeof (RootContext)] as RootContext;
if (fieldHolder != null && fieldHolder != _errorMarker && value != _errorMarker) {
if (fieldRef.TargetObject is CodeThisReferenceExpression && context != null && context.Value == fieldHolder) {
// Do not deserialize the fields of the root component, because the root component type
// is actually an instance of the its parent type, e.g: CustomControl : _UserControl_
// and thus it doesn't contain the fields. The trick is that once DeserializeExpression
// is called on a CodeObjectCreateExpression the component is created and is added to the name-instance
// table.
//
} else {
if (fieldHolder is Type) // static field
field = ((Type)fieldHolder).GetField (fieldRef.FieldName,
BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
else // instance field
field = fieldHolder.GetType().GetField (fieldRef.FieldName,
BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
if (field != null)
field.SetValue (fieldHolder, value);
else {
ReportError (manager, "Field '" + fieldRef.FieldName + "' missing in type '" +
fieldHolder.GetType ().Name + "'",
"Field Name: " + fieldRef.FieldName + System.Environment.NewLine +
"Field is: " + (fieldHolder is Type ? "static" : "instance") + System.Environment.NewLine +
"Field Value: " + (value == null ? "null" : value.ToString()) + System.Environment.NewLine +
"Field Holder Type: " + fieldHolder.GetType ().Name + System.Environment.NewLine +
"Field Holder Expression Type: " + fieldRef.TargetObject.GetType ().Name);
}
}
}
}
// Assign to a Variable
//
CodeVariableReferenceExpression varRef = leftExpr as CodeVariableReferenceExpression;
if (varRef != null && varRef.VariableName != null) {
object value = DeserializeExpression (manager, varRef.VariableName, statement.Right);
// If .Right is not CodeObjectCreateExpression the instance won't be assigned a name,
// so do it ourselves
if (value != _errorMarker && manager.GetName (value) == null)
manager.SetName (value, varRef.VariableName);
}
}
示例4: GetUniqueName
protected string GetUniqueName (IDesignerSerializationManager manager, object instance)
{
if (instance == null)
throw new ArgumentNullException ("instance");
if (manager == null)
throw new ArgumentNullException ("manager");
string name = manager.GetName (instance);
if (name == null) {
INameCreationService service = manager.GetService (typeof (INameCreationService)) as INameCreationService;
name = service.CreateName (null, instance.GetType ());
if (name == null)
name = instance.GetType ().Name.ToLower ();
manager.SetName (instance, name);
}
return name;
}
示例5: ResolveName
private bool ResolveName(IDesignerSerializationManager manager, string name, bool canInvokeManager)
{
bool flag = false;
CodeDomSerializerBase.OrderedCodeStatementCollection codeObject = this._statementsTable[name] as CodeDomSerializerBase.OrderedCodeStatementCollection;
object[] objArray = (object[]) this._objectState[name];
if (name.IndexOf('.') > 0)
{
string outerComponent = null;
IComponent instance = this.ResolveNestedName(manager, name, ref outerComponent);
if ((instance != null) && (outerComponent != null))
{
manager.SetName(instance, name);
this.ResolveName(manager, outerComponent, canInvokeManager);
}
}
if (codeObject == null)
{
flag = this._statementsTable[name] != null;
if (!flag)
{
if (this._expressions.ContainsKey(name))
{
ArrayList list2 = this._expressions[name];
foreach (CodeExpression expression2 in list2)
{
object obj3 = base.DeserializeExpression(manager, name, expression2);
if (((obj3 != null) && !flag) && (canInvokeManager && (manager.GetInstance(name) == null)))
{
manager.SetName(obj3, name);
flag = true;
}
}
}
if (!flag && canInvokeManager)
{
flag = manager.GetInstance(name) != null;
}
if ((flag && (objArray != null)) && (objArray[2] != null))
{
this.DeserializeDefaultProperties(manager, name, objArray[2]);
}
if ((flag && (objArray != null)) && (objArray[3] != null))
{
this.DeserializeDesignTimeProperties(manager, name, objArray[3]);
}
if ((flag && (objArray != null)) && (objArray[4] != null))
{
this.DeserializeEventResets(manager, name, objArray[4]);
}
if ((flag && (objArray != null)) && (objArray[5] != null))
{
DeserializeModifier(manager, name, objArray[5]);
}
}
if (!flag && (flag || canInvokeManager))
{
manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("CodeDomComponentSerializationServiceDeserializationError", new object[] { name }), manager));
}
return flag;
}
this._objectState[name] = null;
this._statementsTable[name] = null;
string typeName = null;
foreach (CodeStatement statement in codeObject)
{
CodeVariableDeclarationStatement statement2 = statement as CodeVariableDeclarationStatement;
if (statement2 != null)
{
typeName = statement2.Type.BaseType;
break;
}
}
if (typeName != null)
{
Type valueType = manager.GetType(typeName);
if (valueType == null)
{
manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerTypeNotFound", new object[] { typeName }), manager));
goto Label_01DA;
}
if ((codeObject == null) || (codeObject.Count <= 0))
{
goto Label_01DA;
}
CodeDomSerializer serializer = base.GetSerializer(manager, valueType);
if (serializer == null)
{
manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { valueType.FullName }), manager));
goto Label_01DA;
}
try
{
object obj2 = serializer.Deserialize(manager, codeObject);
flag = obj2 != null;
if (flag)
{
this._statementsTable[name] = obj2;
}
goto Label_01DA;
}
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:CodeDomComponentSerializationService.cs
示例6: DeserializeExpression
//.........这里部分代码省略.........
}
list.Add(o);
}
}
catch (Exception exception)
{
manager.ReportError(exception);
}
}
array = Array.CreateInstance(type6, list.Count);
list.CopyTo(array, 0);
}
else if (expression11.SizeExpression != null)
{
IConvertible convertible2 = this.DeserializeExpression(manager, name, expression11.SizeExpression) as IConvertible;
if (convertible2 != null)
{
int length = convertible2.ToInt32(null);
array = Array.CreateInstance(type6, length);
}
}
else
{
array = Array.CreateInstance(type6, expression11.Size);
}
}
else
{
Error(manager, System.Design.SR.GetString("SerializerTypeNotFound", new object[] { expression11.CreateType.BaseType }), "SerializerTypeNotFound");
}
instance = array;
if ((instance != null) && (name != null))
{
manager.SetName(instance, name);
}
return instance;
}
CodeArrayIndexerExpression expression12 = instance as CodeArrayIndexerExpression;
if (expression12 != null)
{
instance = null;
Array array2 = this.DeserializeExpression(manager, name, expression12.TargetObject) as Array;
if (array2 != null)
{
int[] indices = new int[expression12.Indices.Count];
bool flag3 = true;
for (int m = 0; m < indices.Length; m++)
{
IConvertible convertible3 = this.DeserializeExpression(manager, name, expression12.Indices[m]) as IConvertible;
if (convertible3 != null)
{
indices[m] = convertible3.ToInt32(null);
}
else
{
flag3 = false;
break;
}
}
if (flag3)
{
instance = array2.GetValue(indices);
}
}
return instance;
}
示例7: DeserializeAssignStatement
private void DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
{
using (TraceScope("CodeDomSerializerBase::DeserializeAssignStatement"))
{
CodeExpression left = statement.Left;
CodePropertyReferenceExpression propertyReferenceEx = left as CodePropertyReferenceExpression;
if (propertyReferenceEx != null)
{
this.DeserializePropertyAssignStatement(manager, statement, propertyReferenceEx, true);
}
else
{
CodeFieldReferenceExpression expression3 = left as CodeFieldReferenceExpression;
if (expression3 != null)
{
object instance = this.DeserializeExpression(manager, expression3.FieldName, expression3.TargetObject);
if (instance != null)
{
RootContext context = (RootContext) manager.Context[typeof(RootContext)];
if ((context != null) && (context.Value == instance))
{
if (this.DeserializeExpression(manager, expression3.FieldName, statement.Right) is CodeExpression)
{
}
}
else
{
FieldInfo field;
object obj4;
Type type = instance as Type;
if (type != null)
{
obj4 = null;
field = GetReflectionTypeFromTypeHelper(manager, type).GetField(expression3.FieldName, BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
}
else
{
obj4 = instance;
field = GetReflectionTypeHelper(manager, instance).GetField(expression3.FieldName, BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
}
if (field != null)
{
object obj5 = this.DeserializeExpression(manager, expression3.FieldName, statement.Right);
if (!(obj5 is CodeExpression))
{
IConvertible convertible = obj5 as IConvertible;
if (convertible != null)
{
Type fieldType = field.FieldType;
TypeDescriptionProvider targetFrameworkProviderForType = GetTargetFrameworkProviderForType(manager, fieldType);
if (targetFrameworkProviderForType != null)
{
fieldType = targetFrameworkProviderForType.GetRuntimeType(fieldType);
}
if (fieldType != obj5.GetType())
{
try
{
obj5 = convertible.ToType(fieldType, null);
}
catch
{
}
}
}
field.SetValue(obj4, obj5);
}
}
else
{
CodePropertyReferenceExpression expression6 = new CodePropertyReferenceExpression {
TargetObject = expression3.TargetObject,
PropertyName = expression3.FieldName
};
if (!this.DeserializePropertyAssignStatement(manager, statement, expression6, false))
{
Error(manager, System.Design.SR.GetString("SerializerNoSuchField", new object[] { instance.GetType().FullName, expression3.FieldName }), "SerializerNoSuchField");
}
}
}
}
}
else
{
CodeVariableReferenceExpression expression4 = left as CodeVariableReferenceExpression;
if (expression4 != null)
{
object obj6 = this.DeserializeExpression(manager, expression4.VariableName, statement.Right);
if (!(obj6 is CodeExpression))
{
manager.SetName(obj6, expression4.VariableName);
}
}
else
{
CodeArrayIndexerExpression expression5 = left as CodeArrayIndexerExpression;
if (expression5 != null)
{
int[] indices = new int[expression5.Indices.Count];
object obj7 = this.DeserializeExpression(manager, null, expression5.TargetObject);
//.........这里部分代码省略.........
示例8: GetUniqueName
protected string GetUniqueName(IDesignerSerializationManager manager, object value)
{
string str2;
if (manager == null)
{
throw new ArgumentNullException("manager");
}
if (value == null)
{
throw new ArgumentNullException("value");
}
string name = manager.GetName(value);
if (name != null)
{
return name;
}
Type reflectionTypeHelper = GetReflectionTypeHelper(manager, value);
INameCreationService service = manager.GetService(typeof(INameCreationService)) as INameCreationService;
if (service != null)
{
str2 = service.CreateName(null, reflectionTypeHelper);
}
else
{
str2 = reflectionTypeHelper.Name.ToLower(CultureInfo.InvariantCulture);
}
int num = 1;
ComponentCache cache = manager.Context[typeof(ComponentCache)] as ComponentCache;
while (true)
{
name = string.Format(CultureInfo.CurrentCulture, "{0}{1}", new object[] { str2, num });
if ((manager.GetInstance(name) == null) && ((cache == null) || !cache.ContainsLocalName(name)))
{
manager.SetName(value, name);
ComponentCache.Entry entry = manager.Context[typeof(ComponentCache.Entry)] as ComponentCache.Entry;
if (entry != null)
{
entry.AddLocalName(name);
}
return name;
}
num++;
}
}