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


C# IDesignerSerializationManager.GetService方法代码示例

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


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

示例1: ComponentCache

 internal ComponentCache(IDesignerSerializationManager manager)
 {
     this.serManager = manager;
     IComponentChangeService service = (IComponentChangeService) manager.GetService(typeof(IComponentChangeService));
     if (service != null)
     {
         service.ComponentChanging += new ComponentChangingEventHandler(this.OnComponentChanging);
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         service.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemove);
         service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemove);
         service.ComponentRename += new ComponentRenameEventHandler(this.OnComponentRename);
     }
     DesignerOptionService service2 = manager.GetService(typeof(DesignerOptionService)) as DesignerOptionService;
     object obj2 = null;
     if (service2 != null)
     {
         PropertyDescriptor descriptor = service2.Options.Properties["UseOptimizedCodeGeneration"];
         if (descriptor != null)
         {
             obj2 = descriptor.GetValue(null);
         }
         if ((obj2 != null) && (obj2 is bool))
         {
             this.enabled = (bool) obj2;
         }
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:27,代码来源:ComponentCache.cs

示例2: ShouldSerialize

		public override bool ShouldSerialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor)
		{
			IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
			if (service != null) // serialize only if there is an event to serialize
				return service.GetEventProperty ((EventDescriptor)descriptor).GetValue (value) != null;
			return false;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:EventCodeDomSerializer.cs

示例3: WorkflowMarkupSerializationManager

 public WorkflowMarkupSerializationManager(IDesignerSerializationManager manager)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     this.serializationManager = manager;
     this.AddSerializationProvider(new WellKnownTypeSerializationProvider());
     this.AddMappings(WorkflowMarkupSerializerMapping.WellKnownMappings);
     ITypeProvider service = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
     if (service != null)
     {
         this.LocalAssembly = service.LocalAssembly;
     }
     this.designMode = manager.GetService(typeof(ITypeResolutionService)) != null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:WorkflowMarkupSerializationManager.cs

示例4: Serialize

		public override void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, 
						CodeStatementCollection statements)
		{
			if (statements == null)
				throw new ArgumentNullException ("statements");
			if (manager == null)
				throw new ArgumentNullException ("manager");
			if (value == null)
				throw new ArgumentNullException ("value");
			if (descriptor == null)
				throw new ArgumentNullException ("descriptor");

			IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
			if (service != null) {
				EventDescriptor eventDescriptor = (EventDescriptor) descriptor;
				string methodName = (string) service.GetEventProperty (eventDescriptor).GetValue (value);

				if (methodName != null) {
					CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression (new CodeTypeReference (eventDescriptor.EventType),
																							   _thisReference, methodName);
					CodeExpression targetObject = base.SerializeToExpression (manager, value);
					CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression (targetObject, eventDescriptor.Name);
					statements.Add (new CodeAttachEventStatement (eventRef, listener));
				}
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:26,代码来源:EventCodeDomSerializer.cs

示例5: Serialize

		public override void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements)
		{
			if (statements == null)
				throw new ArgumentNullException ("statements");
			if (manager == null)
				throw new ArgumentNullException ("manager");
			if (value == null)
				throw new ArgumentNullException ("value");
			if (descriptor == null)
				throw new ArgumentNullException ("descriptor");

			IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
			if (service != null) {
				// In the propertygrid the events are represented by PropertyDescriptors and the value is a string
				// which contains the method name to bind to. The propertydescriptors are managed and created by the 
				// IEventBindingService
				// 
				EventDescriptor ev = (EventDescriptor) descriptor;
				string methodName = (string) service.GetEventProperty (ev).GetValue (value);
				CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression (new CodeTypeReference (ev.EventType), _thisReference, methodName);
				CodeExpression targetObject = base.SerializeToExpression (manager, value);
				CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression (targetObject, ev.Name);
				statements.Add (new CodeAttachEventStatement (eventRef, listener));
			}
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:25,代码来源:EventCodeDomSerializer.cs

示例6: Serialize

        public override object Serialize(IDesignerSerializationManager manager, object value) {
            var baseSerializer = (CodeDomSerializer)manager
                .GetSerializer(typeof(ResourceManagerSetter).BaseType, typeof(CodeDomSerializer));
            object codeObject = baseSerializer.Serialize(manager, value);

            var statements = codeObject as CodeStatementCollection;
            if (statements != null) {
                CodeExpression leftCodeExpression = new CodeVariableReferenceExpression("resources");
                var classTypeDeclaration = (CodeTypeDeclaration)manager.GetService(typeof(CodeTypeDeclaration));
                CodeExpression typeofExpression = new CodeTypeOfExpression(classTypeDeclaration.Name);
                CodeExpression rightCodeExpression =
                    new CodeObjectCreateExpression(typeof(XafComponentResourceManager),
                                                                  new[] { typeofExpression });
                //CodeExpression rightCodeExpression =
                //    new CodeTypeReferenceExpression(
                //        "new DevExpress.ExpressApp.Win.Templates"),
                //        "XafComponentResourceManager", new[] { typeofExpression });

                statements.Insert(0, new CodeAssignStatement(leftCodeExpression, rightCodeExpression));
            }

            return codeObject;


        }
开发者ID:aries544,项目名称:eXpand,代码行数:25,代码来源:ResourceManagerSetter.cs

示例7: WorkflowMarkupSerializationManager

        public WorkflowMarkupSerializationManager(IDesignerSerializationManager manager)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");

            this.serializationManager = manager;
            AddSerializationProvider(new WellKnownTypeSerializationProvider());

            // push standard mappings
            AddMappings(WorkflowMarkupSerializerMapping.WellKnownMappings);

            //Set the local assembly correctly
            ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
            if (typeProvider != null)
                LocalAssembly = typeProvider.LocalAssembly;

            this.designMode = (manager.GetService(typeof(ITypeResolutionService)) != null);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:18,代码来源:WorkflowMarkupSerializationManager.cs

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

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

示例10: Serialize

        public override object Serialize(IDesignerSerializationManager manager, object value)
        {

            CodeExpression expression = new CodePrimitiveExpression(value);

            if (value == null
                || value is bool
                || value is char
                || value is int
                || value is float
                || value is double)
            {

                // work aroundf for J#, since they don't support auto-boxing of value types yet.
                CodeDomProvider codeProvider = manager.GetService(typeof(CodeDomProvider)) as CodeDomProvider;
                if (codeProvider != null && String.Equals(codeProvider.FileExtension, JSharpFileExtension))
                {
                    // See if we are boxing - if so, insert a cast.
                    ExpressionContext cxt = manager.Context[typeof(ExpressionContext)] as ExpressionContext;
                    //Debug.Assert(cxt != null, "No expression context on stack - J# boxing cast will not be inserted");
                    if (cxt != null)
                    {
                        if (cxt.ExpressionType == typeof(object))
                        {
                            expression = new CodeCastExpression(value.GetType(), expression);
                            expression.UserData.Add("CastIsBoxing", true);
                        }
                    }
                }
                return expression;
            }

            String stringValue = value as string;
            if (stringValue != null)
            {
                // WinWS: The commented code breaks us when we have long strings
                //if (stringValue.Length > 200)
                //{
                // return SerializeToResourceExpression(manager, stringValue);
                //}
                //else 
                return expression;
            }

            // generate a cast for non-int types because we won't parse them properly otherwise because we won't know to convert
            // them to the narrow form.
            //
            return new CodeCastExpression(new CodeTypeReference(value.GetType()), expression);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:49,代码来源:PrimitiveCodeDomSerializer.cs

示例11: Deserialize

 public override object Deserialize(IDesignerSerializationManager manager, object codeObject)
 {
     if ((manager == null) || (codeObject == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "codeObject");
     }
     IContainer service = (IContainer) manager.GetService(typeof(IContainer));
     ArrayList list = null;
     if (service != null)
     {
         list = new ArrayList(service.Components.Count);
         foreach (IComponent component in service.Components)
         {
             Control control = component as Control;
             if (control != null)
             {
                 control.SuspendLayout();
                 list.Add(control);
             }
         }
     }
     object obj2 = null;
     try
     {
         CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer));
         if (serializer == null)
         {
             return null;
         }
         obj2 = serializer.Deserialize(manager, codeObject);
     }
     finally
     {
         if (list != null)
         {
             foreach (Control control2 in list)
             {
                 control2.ResumeLayout(false);
             }
         }
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:43,代码来源:ControlCodeDomSerializer.cs

示例12: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     CodeExpression expression = new CodePrimitiveExpression(value);
     if ((((value == null) || (value is bool)) || ((value is char) || (value is int))) || ((value is float) || (value is double)))
     {
         CodeDomProvider service = manager.GetService(typeof(CodeDomProvider)) as CodeDomProvider;
         if ((service != null) && string.Equals(service.FileExtension, JSharpFileExtension))
         {
             ExpressionContext context = manager.Context[typeof(ExpressionContext)] as ExpressionContext;
             if ((context != null) && (context.ExpressionType == typeof(object)))
             {
                 expression = new CodeCastExpression(value.GetType(), expression);
                 expression.UserData.Add("CastIsBoxing", true);
             }
         }
         return expression;
     }
     if (value is string)
     {
         return expression;
     }
     return new CodeCastExpression(new CodeTypeReference(value.GetType()), expression);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:PrimitiveCodeDomSerializer.cs

示例13: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     object obj2 = this.GetBaseSerializer(manager).Serialize(manager, value);
     TableLayoutPanel component = value as TableLayoutPanel;
     if (component != null)
     {
         InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(component)[typeof(InheritanceAttribute)];
         if ((attribute == null) || (attribute.InheritanceLevel != InheritanceLevel.InheritedReadOnly))
         {
             IDesignerHost service = (IDesignerHost) manager.GetService(typeof(IDesignerHost));
             if (this.IsLocalizable(service))
             {
                 PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)[LayoutSettingsPropName];
                 object obj3 = (descriptor != null) ? descriptor.GetValue(component) : null;
                 if (obj3 != null)
                 {
                     string resourceName = manager.GetName(component) + "." + LayoutSettingsPropName;
                     base.SerializeResourceInvariant(manager, resourceName, obj3);
                 }
             }
         }
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:TableLayoutPanelCodeDomSerializer.cs

示例14: Serialize


//.........这里部分代码省略.........
                                    param1 = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(DependencyProperty)), "FromName", new CodePrimitiveExpression(dependencyProperty.Name), new CodeTypeOfExpression(dependencyProperty.OwnerType));
                                else
                                    param1 = new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dependencyProperty.OwnerType), dependencyPropertyName);

                                CodeExpression param2 = SerializeToExpression(manager, value);

                                //Fields property fails to serialize to expression due to reference not being created,
                                //the actual code for fields are generated in datacontext code generator so we do nothing here
                                if (param1 != null && param2 != null)
                                {
                                    CodeMethodInvokeExpression codeMethodInvokeExpr = null;
                                    if (value is ActivityBind)
                                        codeMethodInvokeExpr = new CodeMethodInvokeExpression(objectExpression, "SetBinding", new CodeExpression[] { param1, new CodeCastExpression(new CodeTypeReference(typeof(ActivityBind)), param2) });
                                    else
                                        codeMethodInvokeExpr = new CodeMethodInvokeExpression(objectExpression, (dependencyProperty.IsEvent) ? "AddHandler" : "SetValue", new CodeExpression[] { param1, param2 });
                                    retVal.Add(codeMethodInvokeExpr);

                                    // Remove the property set statement for the event which is replaced by the SetValue() expression.
                                    foreach (CodeStatement statement in codeStatements)
                                    {
                                        if (statement is CodeAssignStatement && ((CodeAssignStatement)statement).Left is CodePropertyReferenceExpression)
                                        {
                                            CodePropertyReferenceExpression prop = ((CodeAssignStatement)statement).Left as CodePropertyReferenceExpression;
                                            if (prop.PropertyName == dependencyProperty.Name && prop.TargetObject.Equals(objectExpression))
                                                retVal.Remove(statement);
                                        }
                                    }
                                }

                                propertiesSerialized.Add(dependencyProperty);
                            }
                        }

                        IEventBindingService eventBindingService = manager.GetService(typeof(IEventBindingService)) as IEventBindingService;
                        if (eventBindingService == null)
                        {
                            // At compile time, we don't have an event binding service.  We need to mannually emit the code to add
                            // event handlers.
                            foreach (EventDescriptor eventDesc in TypeDescriptor.GetEvents(dependencyObject))
                            {
                                string handler = WorkflowMarkupSerializationHelpers.GetEventHandlerName(dependencyObject, eventDesc.Name);
                                if (!string.IsNullOrEmpty(handler))
                                {
                                    CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression(objectExpression, eventDesc.Name);
                                    CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression(new CodeTypeReference(eventDesc.EventType), new CodeThisReferenceExpression(), handler);
                                    retVal.Add(new CodeAttachEventStatement(eventRef, listener));
                                }
                            }
                        }

                        // We also need to handle properties of type System.Type.  If the value is a design time type, xomlserializer 
                        // is not going to be able to deserialize the type.  We then store the type name in the user data and
                        // output a "typeof(xxx)" expression using the type name w/o validating the type.
                        if (dependencyObject.UserData.Contains(UserDataKeys.DesignTimeTypeNames))
                        {
                            Hashtable typeNames = dependencyObject.UserData[UserDataKeys.DesignTimeTypeNames] as Hashtable;
                            foreach (object key in typeNames.Keys)
                            {
                                string propName = null;
                                string ownerTypeName = null;
                                string typeName = typeNames[key] as string;
                                DependencyProperty dependencyProperty = key as DependencyProperty;
                                if (dependencyProperty != null)
                                {
                                    if (propertiesSerialized.Contains(dependencyProperty))
                                        continue;
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:67,代码来源:DependencyObjectCodeDomSerializer.cs

示例15: DeserializeStatement

		protected void DeserializeStatement (IDesignerSerializationManager manager, CodeStatement statement)
		{
			if (statement == null)
				throw new ArgumentNullException ("statement");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			// CodeAssignStatement
			//
			CodeAssignStatement assignment = statement as CodeAssignStatement;
			if (assignment != null)
				DeserializeAssignmentStatement (manager, assignment);

			// CodeExpressionStatement
			//
			CodeExpressionStatement expression = statement as CodeExpressionStatement;
			if (expression != null)
				this.DeserializeExpression (manager, null, expression.Expression);

			// CodeAttachEventStatement
			//
			CodeAttachEventStatement attachStatement = statement as CodeAttachEventStatement;
			if (attachStatement != null) {
				string methodName = null;

				CodeObjectCreateExpression createExpr = attachStatement.Listener as CodeObjectCreateExpression;
				if (createExpr != null && createExpr.Parameters.Count == 1 ) { // += new EventType (method)
					CodeMethodReferenceExpression handlerRef = createExpr.Parameters[0] as CodeMethodReferenceExpression;
					if (handlerRef != null)
						methodName = handlerRef.MethodName;
				}

				CodeDelegateCreateExpression delegateCreateExpr = attachStatement.Listener as CodeDelegateCreateExpression;
				if (delegateCreateExpr != null)// += new EventType (method)
					methodName = delegateCreateExpr.MethodName;

				CodeMethodReferenceExpression methodRef = attachStatement.Listener as CodeMethodReferenceExpression;
				if (methodRef != null) // += method
					methodName = methodRef.MethodName;

				object component = DeserializeExpression (manager, null, attachStatement.Event.TargetObject);
				if (component != null && component != _errorMarker && methodName != null) {
					string error = null;
					EventDescriptor eventDescriptor = TypeDescriptor.GetEvents (component)[attachStatement.Event.EventName];
					if (eventDescriptor != null) {
						IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
						if (service != null)
							service.GetEventProperty (eventDescriptor).SetValue (component, methodName);
						else
							error = "IEventBindingService missing";
					} else {
						error = "No event '" + attachStatement.Event.EventName + 
							"' found in type '" + component.GetType ().Name + "'";
					}

					if (error != null) {
						ReportError (manager, error, "Method Name: " + methodName + System.Environment.NewLine +
							"Event Name: " + attachStatement.Event.EventName + System.Environment.NewLine +
							"Listener Expression Type: " + methodRef.GetType ().Name + System.Environment.NewLine +
							"Event Holder Type: " + component.GetType ().Name + System.Environment.NewLine +
							"Event Holder Expression Type: " + attachStatement.Event.TargetObject.GetType ().Name);
					}
				}
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:65,代码来源:CodeDomSerializerBase.cs


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