当前位置: 首页>>代码示例>>C#>>正文


C# IDesignerSerializationManager.ReportError方法代码示例

本文整理汇总了C#中IDesignerSerializationManager.ReportError方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerSerializationManager.ReportError方法的具体用法?C# IDesignerSerializationManager.ReportError怎么用?C# IDesignerSerializationManager.ReportError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDesignerSerializationManager的用法示例。


在下文中一共展示了IDesignerSerializationManager.ReportError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPropertyValue

 private object GetPropertyValue(IDesignerSerializationManager manager, PropertyDescriptor property, object value, out bool validValue)
 {
     object obj2 = null;
     validValue = true;
     try
     {
         if (!property.ShouldSerializeValue(value))
         {
             AmbientValueAttribute attribute = (AmbientValueAttribute) property.Attributes[typeof(AmbientValueAttribute)];
             if (attribute != null)
             {
                 return attribute.Value;
             }
             DefaultValueAttribute attribute2 = (DefaultValueAttribute) property.Attributes[typeof(DefaultValueAttribute)];
             if (attribute2 != null)
             {
                 return attribute2.Value;
             }
             validValue = false;
         }
         obj2 = property.GetValue(value);
     }
     catch (Exception exception)
     {
         validValue = false;
         manager.ReportError(System.Design.SR.GetString("SerializerPropertyGenFailed", new object[] { property.Name, exception.Message }));
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:PropertyMemberCodeDomSerializer.cs

示例2: Serialize

 public override void Serialize(IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements)
 {
     EventDescriptor e = descriptor as EventDescriptor;
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (e == null)
     {
         throw new ArgumentNullException("descriptor");
     }
     if (statements == null)
     {
         throw new ArgumentNullException("statements");
     }
     try
     {
         IEventBindingService service = (IEventBindingService) manager.GetService(typeof(IEventBindingService));
         if (service != null)
         {
             string methodName = (string) service.GetEventProperty(e).GetValue(value);
             if (methodName != null)
             {
                 CodeExpression targetObject = base.SerializeToExpression(manager, value);
                 if (targetObject != null)
                 {
                     CodeTypeReference delegateType = new CodeTypeReference(e.EventType);
                     CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression(delegateType, _thisRef, methodName);
                     CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression(targetObject, e.Name);
                     CodeAttachEventStatement statement = new CodeAttachEventStatement(eventRef, listener);
                     statement.UserData[typeof(Delegate)] = e.EventType;
                     statements.Add(statement);
                 }
             }
         }
     }
     catch (Exception innerException)
     {
         if (innerException is TargetInvocationException)
         {
             innerException = innerException.InnerException;
         }
         manager.ReportError(System.Design.SR.GetString("SerializerPropertyGenFailed", new object[] { e.Name, innerException.Message }));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:49,代码来源:EventMemberCodeDomSerializer.cs

示例3: Serialize

 public override void Serialize(IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements)
 {
     PropertyDescriptor property = descriptor as PropertyDescriptor;
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (property == null)
     {
         throw new ArgumentNullException("descriptor");
     }
     if (statements == null)
     {
         throw new ArgumentNullException("statements");
     }
     try
     {
         ExtenderProvidedPropertyAttribute attribute = (ExtenderProvidedPropertyAttribute) property.Attributes[typeof(ExtenderProvidedPropertyAttribute)];
         bool isExtender = (attribute != null) && (attribute.Provider != null);
         if (property.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content))
         {
             this.SerializeContentProperty(manager, value, property, isExtender, statements);
         }
         else if (isExtender)
         {
             this.SerializeExtenderProperty(manager, value, property, statements);
         }
         else
         {
             this.SerializeNormalProperty(manager, value, property, statements);
         }
     }
     catch (Exception innerException)
     {
         if (innerException is TargetInvocationException)
         {
             innerException = innerException.InnerException;
         }
         manager.ReportError(System.Design.SR.GetString("SerializerPropertyGenFailed", new object[] { property.Name, innerException.Message }));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:45,代码来源:PropertyMemberCodeDomSerializer.cs

示例4: SerializeContentProperty

 private void SerializeContentProperty(IDesignerSerializationManager manager, object value, PropertyDescriptor property, bool isExtender, CodeStatementCollection statements)
 {
     bool flag;
     object presetValue = this.GetPropertyValue(manager, property, value, out flag);
     CodeDomSerializer serializer = null;
     if (presetValue == null)
     {
         string name = manager.GetName(value);
         if (name == null)
         {
             name = value.GetType().FullName;
         }
         manager.ReportError(System.Design.SR.GetString("SerializerNullNestedProperty", new object[] { name, property.Name }));
     }
     else
     {
         serializer = (CodeDomSerializer) manager.GetSerializer(presetValue.GetType(), typeof(CodeDomSerializer));
         if (serializer != null)
         {
             CodeExpression targetObject = base.SerializeToExpression(manager, value);
             if (targetObject != null)
             {
                 CodeExpression expression = null;
                 if (isExtender)
                 {
                     ExtenderProvidedPropertyAttribute attribute = (ExtenderProvidedPropertyAttribute) property.Attributes[typeof(ExtenderProvidedPropertyAttribute)];
                     CodeExpression expression3 = base.SerializeToExpression(manager, attribute.Provider);
                     CodeExpression expression4 = base.SerializeToExpression(manager, value);
                     if ((expression3 != null) && (expression4 != null))
                     {
                         CodeMethodReferenceExpression expression5 = new CodeMethodReferenceExpression(expression3, "Get" + property.Name);
                         CodeMethodInvokeExpression expression6 = new CodeMethodInvokeExpression {
                             Method = expression5
                         };
                         expression6.Parameters.Add(expression4);
                         expression = expression6;
                     }
                 }
                 else
                 {
                     expression = new CodePropertyReferenceExpression(targetObject, property.Name);
                 }
                 if (expression != null)
                 {
                     ExpressionContext context = new ExpressionContext(expression, property.PropertyType, value, presetValue);
                     manager.Context.Push(context);
                     object obj3 = null;
                     try
                     {
                         SerializeAbsoluteContext context2 = (SerializeAbsoluteContext) manager.Context[typeof(SerializeAbsoluteContext)];
                         if (base.IsSerialized(manager, presetValue, context2 != null))
                         {
                             obj3 = base.GetExpression(manager, presetValue);
                         }
                         else
                         {
                             obj3 = serializer.Serialize(manager, presetValue);
                         }
                     }
                     finally
                     {
                         manager.Context.Pop();
                     }
                     CodeStatementCollection statements2 = obj3 as CodeStatementCollection;
                     if (statements2 == null)
                     {
                         CodeStatement statement2 = obj3 as CodeStatement;
                         if (statement2 != null)
                         {
                             statements.Add(statement2);
                         }
                     }
                     else
                     {
                         foreach (CodeStatement statement in statements2)
                         {
                             statements.Add(statement);
                         }
                     }
                 }
             }
         }
         else
         {
             manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { property.PropertyType.FullName }));
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:88,代码来源:PropertyMemberCodeDomSerializer.cs

示例5: DeserializeName

 private object DeserializeName(IDesignerSerializationManager manager, string name)
 {
     string typeName = null;
     Type objectType = null;
     object obj2 = this.nameTable[name];
     using (CodeDomSerializerBase.TraceScope("RootCodeDomSerializer::DeserializeName"))
     {
         CodeMemberField field = null;
         CodeObject obj3 = obj2 as CodeObject;
         if (obj3 != null)
         {
             obj2 = null;
             this.nameTable[name] = null;
             if (obj3 is CodeVariableDeclarationStatement)
             {
                 CodeVariableDeclarationStatement statement = (CodeVariableDeclarationStatement) obj3;
                 typeName = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, statement.Type);
             }
             else if (obj3 is CodeMemberField)
             {
                 field = (CodeMemberField) obj3;
                 typeName = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, field.Type);
             }
         }
         else
         {
             if (obj2 != null)
             {
                 return obj2;
             }
             IContainer service = (IContainer) manager.GetService(typeof(IContainer));
             if (service != null)
             {
                 IComponent component = service.Components[name];
                 if (component != null)
                 {
                     typeName = component.GetType().FullName;
                     this.nameTable[name] = component;
                 }
             }
         }
         if (name.Equals(this.ContainerName))
         {
             IContainer container2 = (IContainer) manager.GetService(typeof(IContainer));
             if (container2 != null)
             {
                 obj2 = container2;
             }
         }
         else if (typeName != null)
         {
             objectType = manager.GetType(typeName);
             if (objectType == null)
             {
                 manager.ReportError(new SerializationException(System.Design.SR.GetString("SerializerTypeNotFound", new object[] { typeName })));
             }
             else
             {
                 CodeStatementCollection codeObject = (CodeStatementCollection) this.statementTable[name];
                 if ((codeObject != null) && (codeObject.Count > 0))
                 {
                     CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(objectType, typeof(CodeDomSerializer));
                     if (serializer == null)
                     {
                         manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { objectType.FullName }));
                     }
                     else
                     {
                         try
                         {
                             obj2 = serializer.Deserialize(manager, codeObject);
                             if ((obj2 != null) && (field != null))
                             {
                                 PropertyDescriptor descriptor = TypeDescriptor.GetProperties(obj2)["Modifiers"];
                                 if ((descriptor != null) && (descriptor.PropertyType == typeof(MemberAttributes)))
                                 {
                                     MemberAttributes attributes = field.Attributes & MemberAttributes.AccessMask;
                                     descriptor.SetValue(obj2, attributes);
                                 }
                             }
                         }
                         catch (Exception exception)
                         {
                             manager.ReportError(exception);
                         }
                     }
                 }
             }
         }
         this.nameTable[name] = obj2;
     }
     return obj2;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:93,代码来源:RootCodeDomSerializer.cs

示例6: GetPropertyValue

 private object GetPropertyValue(IDesignerSerializationManager manager, PropertyDescriptor property, object value, out bool validValue)
 {
     object instance = null;
     validValue = true;
     try
     {
         if (!property.ShouldSerializeValue(value))
         {
             AmbientValueAttribute attribute = (AmbientValueAttribute) property.Attributes[typeof(AmbientValueAttribute)];
             if (attribute != null)
             {
                 return attribute.Value;
             }
             DefaultValueAttribute attribute2 = (DefaultValueAttribute) property.Attributes[typeof(DefaultValueAttribute)];
             if (attribute2 != null)
             {
                 return attribute2.Value;
             }
             validValue = false;
         }
         instance = property.GetValue(value);
     }
     catch (Exception exception)
     {
         validValue = false;
         manager.ReportError(System.Design.SR.GetString("SerializerPropertyGenFailed", new object[] { property.Name, exception.Message }));
     }
     if (((instance != null) && !instance.GetType().IsValueType) && !TypeDescriptor.GetProvider(instance).GetReflectionType(typeof(object)).IsDefined(typeof(ProjectTargetFrameworkAttribute), false))
     {
         TypeDescriptionProvider targetFrameworkProvider = CodeDomSerializerBase.GetTargetFrameworkProvider(manager, instance);
         if (targetFrameworkProvider != null)
         {
             TypeDescriptor.AddProvider(targetFrameworkProvider, instance);
         }
     }
     return instance;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:37,代码来源:PropertyMemberCodeDomSerializer.cs

示例7: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     if ((manager == null) || (value == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "value");
     }
     CodeTypeDeclaration declaration = new CodeTypeDeclaration(manager.GetName(value));
     RootContext context = new RootContext(new CodeThisReferenceExpression(), value);
     using (CodeDomSerializerBase.TraceScope("RootCodeDomSerializer::Serialize"))
     {
         declaration.BaseTypes.Add(value.GetType());
         this.containerRequired = false;
         manager.Context.Push(context);
         manager.Context.Push(this);
         manager.Context.Push(declaration);
         if (!(manager is DesignerSerializationManager))
         {
             manager.AddSerializationProvider(new CodeDomSerializationProvider());
         }
         try
         {
             if (value is IComponent)
             {
                 ISite site = ((IComponent) value).Site;
                 if (site == null)
                 {
                     return declaration;
                 }
                 ICollection components = site.Container.Components;
                 StatementContext context2 = new StatementContext();
                 context2.StatementCollection.Populate(components);
                 manager.Context.Push(context2);
                 try
                 {
                     foreach (IComponent component in components)
                     {
                         if ((component != value) && !base.IsSerialized(manager, component))
                         {
                             if (base.GetSerializer(manager, component) != null)
                             {
                                 base.SerializeToExpression(manager, component);
                             }
                             else
                             {
                                 manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { component.GetType().FullName }));
                             }
                         }
                     }
                     manager.Context.Push(value);
                     try
                     {
                         if ((base.GetSerializer(manager, value) != null) && !base.IsSerialized(manager, value))
                         {
                             base.SerializeToExpression(manager, value);
                         }
                         else
                         {
                             manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { value.GetType().FullName }));
                         }
                     }
                     finally
                     {
                         manager.Context.Pop();
                     }
                 }
                 finally
                 {
                     manager.Context.Pop();
                 }
                 CodeMemberMethod method = new CodeMemberMethod {
                     Name = this.InitMethodName,
                     Attributes = MemberAttributes.Private
                 };
                 declaration.Members.Add(method);
                 ArrayList elements = new ArrayList();
                 foreach (object obj2 in components)
                 {
                     if (obj2 != value)
                     {
                         elements.Add(context2.StatementCollection[obj2]);
                     }
                 }
                 if (context2.StatementCollection[value] != null)
                 {
                     elements.Add(context2.StatementCollection[value]);
                 }
                 if (this.ContainerRequired)
                 {
                     this.SerializeContainerDeclaration(manager, method.Statements);
                 }
                 this.SerializeElementsToStatements(elements, method.Statements);
             }
             return declaration;
         }
         finally
         {
             manager.Context.Pop();
             manager.Context.Pop();
             manager.Context.Pop();
         }
//.........这里部分代码省略.........
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:101,代码来源:RootCodeDomSerializer.cs

示例8: FillStatementTable


//.........这里部分代码省略.........
             {
                 left = expression6.TargetObject;
                 goto Label_00E4;
             }
             CodeMethodInvokeExpression expression7 = left as CodeMethodInvokeExpression;
             if (expression7 != null)
             {
                 left = expression7.Method;
                 goto Label_00E4;
             }
             CodeMethodReferenceExpression expression8 = left as CodeMethodReferenceExpression;
             if (expression8 != null)
             {
                 left = expression8.TargetObject;
                 goto Label_00E4;
             }
             CodeArrayIndexerExpression expression9 = left as CodeArrayIndexerExpression;
             if (expression9 != null)
             {
                 left = expression9.TargetObject;
                 goto Label_00E4;
             }
             CodeFieldReferenceExpression expression10 = left as CodeFieldReferenceExpression;
             if (expression10 != null)
             {
                 bool flag = false;
                 if (expression10.TargetObject is CodeThisReferenceExpression)
                 {
                     Type objectType = GetType(manager, expression10.FieldName, names);
                     if (objectType != null)
                     {
                         CodeDomSerializer serializer = manager.GetSerializer(objectType, typeof(CodeDomSerializer)) as CodeDomSerializer;
                         if (serializer != null)
                         {
                             string str = serializer.GetTargetComponentName(statement6, left, objectType);
                             if (!string.IsNullOrEmpty(str))
                             {
                                 AddStatement(table, str, statement6);
                                 flag = true;
                             }
                         }
                     }
                     if (!flag)
                     {
                         AddStatement(table, expression10.FieldName, statement6);
                     }
                     continue;
                 }
                 left = expression10.TargetObject;
                 goto Label_00E4;
             }
             CodePropertyReferenceExpression expression11 = left as CodePropertyReferenceExpression;
             if (expression11 != null)
             {
                 if ((expression11.TargetObject is CodeThisReferenceExpression) && ((names == null) || names.ContainsKey(expression11.PropertyName)))
                 {
                     AddStatement(table, expression11.PropertyName, statement6);
                     continue;
                 }
                 left = expression11.TargetObject;
                 goto Label_00E4;
             }
             CodeVariableReferenceExpression expression12 = left as CodeVariableReferenceExpression;
             if (expression12 != null)
             {
                 bool flag2 = false;
                 if (names != null)
                 {
                     Type type2 = GetType(manager, expression12.VariableName, names);
                     if (type2 != null)
                     {
                         CodeDomSerializer serializer2 = manager.GetSerializer(type2, typeof(CodeDomSerializer)) as CodeDomSerializer;
                         if (serializer2 != null)
                         {
                             string str2 = serializer2.GetTargetComponentName(statement6, left, type2);
                             if (!string.IsNullOrEmpty(str2))
                             {
                                 AddStatement(table, str2, statement6);
                                 flag2 = true;
                             }
                         }
                     }
                 }
                 else
                 {
                     AddStatement(table, expression12.VariableName, statement6);
                     flag2 = true;
                 }
                 if (!flag2)
                 {
                     manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerUndeclaredName", new object[] { expression12.VariableName }), manager));
                 }
             }
             else if (((left is CodeThisReferenceExpression) || (left is CodeBaseReferenceExpression)) && (className != null))
             {
                 AddStatement(table, className, statement6);
             }
         }
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:101,代码来源:CodeDomSerializerBase.cs

示例9: 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

示例10: SerializeToExpression

 protected CodeExpression SerializeToExpression(IDesignerSerializationManager manager, object value)
 {
     CodeExpression legacyExpression = null;
     using (TraceScope("SerializeToExpression"))
     {
         if (value != null)
         {
             if (this.IsSerialized(manager, value))
             {
                 legacyExpression = this.GetExpression(manager, value);
             }
             else
             {
                 legacyExpression = this.GetLegacyExpression(manager, value);
                 if (legacyExpression != null)
                 {
                     this.SetExpression(manager, value, legacyExpression);
                 }
             }
         }
         if (legacyExpression != null)
         {
             return legacyExpression;
         }
         CodeDomSerializer serializer = this.GetSerializer(manager, value);
         if (serializer != null)
         {
             CodeStatementCollection statements = null;
             if (value != null)
             {
                 this.SetLegacyExpression(manager, value);
                 StatementContext context = manager.Context[typeof(StatementContext)] as StatementContext;
                 if (context != null)
                 {
                     statements = context.StatementCollection[value];
                 }
                 if (statements != null)
                 {
                     manager.Context.Push(statements);
                 }
             }
             object obj2 = null;
             try
             {
                 obj2 = serializer.Serialize(manager, value);
             }
             finally
             {
                 if (statements != null)
                 {
                     manager.Context.Pop();
                 }
             }
             legacyExpression = obj2 as CodeExpression;
             if ((legacyExpression == null) && (value != null))
             {
                 legacyExpression = this.GetExpression(manager, value);
             }
             CodeStatementCollection statements2 = obj2 as CodeStatementCollection;
             if (statements2 == null)
             {
                 CodeStatement statement = obj2 as CodeStatement;
                 if (statement != null)
                 {
                     statements2 = new CodeStatementCollection();
                     statements2.Add(statement);
                 }
             }
             if (statements2 != null)
             {
                 if (statements == null)
                 {
                     statements = manager.Context[typeof(CodeStatementCollection)] as CodeStatementCollection;
                 }
                 if (statements != null)
                 {
                     statements.AddRange(statements2);
                     return legacyExpression;
                 }
                 string name = "(null)";
                 if (value != null)
                 {
                     name = manager.GetName(value);
                     if (name == null)
                     {
                         name = value.GetType().Name;
                     }
                 }
                 manager.ReportError(System.Design.SR.GetString("SerializerLostStatements", new object[] { name }));
             }
             return legacyExpression;
         }
         manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { value.GetType().FullName }));
     }
     return legacyExpression;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:96,代码来源:CodeDomSerializerBase.cs

示例11: DeserializeExpression


//.........这里部分代码省略.........
                 RootContext context3 = (RootContext) manager.Context[typeof(RootContext)];
                 if (context3 != null)
                 {
                     return context3.Value;
                 }
                 return null;
             }
             CodeArrayCreateExpression expression11 = instance as CodeArrayCreateExpression;
             if (expression11 != null)
             {
                 Type type6 = manager.GetType(GetTypeNameFromCodeTypeReference(manager, expression11.CreateType));
                 Array array = null;
                 if (type6 != null)
                 {
                     if (expression11.Initializers.Count > 0)
                     {
                         ArrayList list = new ArrayList(expression11.Initializers.Count);
                         foreach (CodeExpression expression22 in expression11.Initializers)
                         {
                             try
                             {
                                 object o = this.DeserializeExpression(manager, null, expression22);
                                 if (!(o is CodeExpression))
                                 {
                                     if (!type6.IsInstanceOfType(o))
                                     {
                                         o = Convert.ChangeType(o, type6, CultureInfo.InvariantCulture);
                                     }
                                     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)
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:67,代码来源:CodeDomSerializerBase.cs

示例12: DeserializeStatement

 protected void DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
 {
     using (TraceScope("CodeDomSerializerBase::DeserializeStatement"))
     {
         manager.Context.Push(statement);
         try
         {
             CodeAssignStatement statement2 = statement as CodeAssignStatement;
             if (statement2 != null)
             {
                 this.DeserializeAssignStatement(manager, statement2);
             }
             else
             {
                 CodeVariableDeclarationStatement statement3 = statement as CodeVariableDeclarationStatement;
                 if (statement3 != null)
                 {
                     this.DeserializeVariableDeclarationStatement(manager, statement3);
                 }
                 else if (!(statement is CodeCommentStatement))
                 {
                     CodeExpressionStatement statement4 = statement as CodeExpressionStatement;
                     if (statement4 != null)
                     {
                         this.DeserializeExpression(manager, null, statement4.Expression);
                     }
                     else if (statement is CodeMethodReturnStatement)
                     {
                         this.DeserializeExpression(manager, null, statement4.Expression);
                     }
                     else
                     {
                         CodeAttachEventStatement statement6 = statement as CodeAttachEventStatement;
                         if (statement6 != null)
                         {
                             this.DeserializeAttachEventStatement(manager, statement6);
                         }
                         else
                         {
                             CodeRemoveEventStatement statement7 = statement as CodeRemoveEventStatement;
                             if (statement7 != null)
                             {
                                 this.DeserializeDetachEventStatement(manager, statement7);
                             }
                             else
                             {
                                 CodeLabeledStatement statement8 = statement as CodeLabeledStatement;
                                 if (statement8 != null)
                                 {
                                     this.DeserializeStatement(manager, statement8.Statement);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         catch (CheckoutException)
         {
             throw;
         }
         catch (Exception innerException)
         {
             if (innerException is TargetInvocationException)
             {
                 innerException = innerException.InnerException;
             }
             if (!(innerException is CodeDomSerializerException) && (statement.LinePragma != null))
             {
                 innerException = new CodeDomSerializerException(innerException, statement.LinePragma);
             }
             manager.ReportError(innerException);
         }
         finally
         {
             manager.Context.Pop();
         }
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:79,代码来源:CodeDomSerializerBase.cs

示例13: DeserializePropertiesFromResources

 protected void DeserializePropertiesFromResources(IDesignerSerializationManager manager, object value, Attribute[] filter)
 {
     using (TraceScope("ComponentCodeDomSerializerBase::DeserializePropertiesFromResources"))
     {
         IDictionaryEnumerator metadataEnumerator = ResourceCodeDomSerializer.Default.GetMetadataEnumerator(manager);
         if (metadataEnumerator == null)
         {
             metadataEnumerator = ResourceCodeDomSerializer.Default.GetEnumerator(manager, CultureInfo.InvariantCulture);
         }
         if (metadataEnumerator != null)
         {
             string name;
             RootContext context = manager.Context[typeof(RootContext)] as RootContext;
             if ((context != null) && (context.Value == value))
             {
                 name = "$this";
             }
             else
             {
                 name = manager.GetName(value);
             }
             PropertyDescriptorCollection descriptors = GetPropertiesHelper(manager, value, null);
             while (metadataEnumerator.MoveNext())
             {
                 string key = metadataEnumerator.Key as string;
                 int index = key.IndexOf('.');
                 if ((index != -1) && key.Substring(0, index).Equals(name))
                 {
                     string str4 = key.Substring(index + 1);
                     PropertyDescriptor descriptor = descriptors[str4];
                     if (descriptor != null)
                     {
                         bool flag = true;
                         if (filter != null)
                         {
                             AttributeCollection attributes = descriptor.Attributes;
                             foreach (Attribute attribute in filter)
                             {
                                 if (!attributes.Contains(attribute))
                                 {
                                     flag = false;
                                     break;
                                 }
                             }
                         }
                         if (flag)
                         {
                             object obj2 = metadataEnumerator.Value;
                             try
                             {
                                 descriptor.SetValue(value, obj2);
                                 continue;
                             }
                             catch (Exception exception)
                             {
                                 manager.ReportError(exception);
                                 continue;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:65,代码来源:CodeDomSerializerBase.cs

示例14: Serialize


//.........这里部分代码省略.........
                         if (container2 != null)
                         {
                             serviceInstance = new ComponentCache(manager);
                             container2.AddService(typeof(ComponentCache), serviceInstance);
                         }
                     }
                     else if (((manager == manager2) && (serviceInstance != null)) && serviceInstance.Enabled)
                     {
                         entry = serviceInstance[value];
                     }
                     if ((entry == null) || entry.Tracking)
                     {
                         if (entry == null)
                         {
                             entry = new ComponentCache.Entry(serviceInstance);
                             ComponentCache.Entry entryAll = null;
                             entryAll = serviceInstance.GetEntryAll(value);
                             if (((entryAll != null) && (entryAll.Dependencies != null)) && (entryAll.Dependencies.Count > 0))
                             {
                                 foreach (object obj2 in entryAll.Dependencies)
                                 {
                                     entry.AddDependency(obj2);
                                 }
                             }
                         }
                         entry.Component = value;
                         bool flag8 = manager == manager2;
                         entry.Valid = flag8 && this.CanCacheComponent(manager, value, properties);
                         if ((flag8 && (serviceInstance != null)) && serviceInstance.Enabled)
                         {
                             manager.Context.Push(serviceInstance);
                             manager.Context.Push(entry);
                         }
                         try
                         {
                             entry.Statements = new CodeStatementCollection();
                             base.SerializeProperties(manager, entry.Statements, value, _runTimeFilter);
                             base.SerializeEvents(manager, entry.Statements, value, null);
                             foreach (CodeStatement statement3 in entry.Statements)
                             {
                                 if (statement3 is CodeVariableDeclarationStatement)
                                 {
                                     entry.Tracking = true;
                                     break;
                                 }
                             }
                             if (entry.Statements.Count > 0)
                             {
                                 entry.Statements.Insert(0, new CodeCommentStatement(string.Empty));
                                 entry.Statements.Insert(0, new CodeCommentStatement(name));
                                 entry.Statements.Insert(0, new CodeCommentStatement(string.Empty));
                                 if ((flag8 && (serviceInstance != null)) && serviceInstance.Enabled)
                                 {
                                     serviceInstance[value] = entry;
                                 }
                             }
                         }
                         finally
                         {
                             if ((flag8 && (serviceInstance != null)) && serviceInstance.Enabled)
                             {
                                 manager.Context.Pop();
                                 manager.Context.Pop();
                             }
                         }
                     }
                     else if (((entry.Resources != null) || (entry.Metadata != null)) && ((serviceInstance != null) && serviceInstance.Enabled))
                     {
                         ResourceCodeDomSerializer.Default.ApplyCacheEntry(manager, entry);
                     }
                     statements.AddRange(entry.Statements);
                     if (flag7)
                     {
                         this.SerializeLoadComponentSettings(manager, statements, left, value);
                     }
                     if (flag6)
                     {
                         this.SerializeSupportInitialize(manager, statements, left, value, "EndInit");
                     }
                 }
                 return statements;
             }
             catch (CheckoutException)
             {
                 throw;
             }
             catch (Exception exception)
             {
                 manager.ReportError(exception);
             }
             return statements;
         }
         finally
         {
             manager.Context.Pop();
             manager.Context.Pop();
         }
     }
     return statements;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ComponentCodeDomSerializer.cs

示例15: ReportError

		internal void ReportError (IDesignerSerializationManager manager, string message, string details)
		{
			try {
				throw new Exception (message);
			} catch (Exception e) {
				e.Data["Details"] = message + Environment.NewLine + Environment.NewLine + details;
				manager.ReportError (e);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:CodeDomSerializerBase.cs


注:本文中的IDesignerSerializationManager.ReportError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。