public static void AddAttribute(IAttributeHolder holder, CodeAttributeDeclarationCollection attributs, bool isWebService, bool includeOperationContract, string namespaceText)
        {
            List <ConstObjectPointer> list = holder.GetCustomAttributeList();

            if (list != null && list.Count > 0)
            {
                foreach (ConstObjectPointer cop in list)
                {
                    if (!includeOperationContract)
                    {
                        if (typeof(OperationContractAttribute).IsAssignableFrom(cop.BaseClassType))
                        {
                            continue;
                        }
                    }
                    if (!isWebService)
                    {
                        if (typeof(WebServiceAttribute).Equals(cop.BaseClassType))
                        {
                            isWebService = true;
                        }
                    }
                    CodeAttributeArgument[] aa = new CodeAttributeArgument[cop.ParameterCount];
                    for (int i = 0; i < cop.ParameterCount; i++)
                    {
                        aa[i] = new CodeAttributeArgument(cop.GetParameterCode(null, null, i));
                    }
                    CodeAttributeDeclaration a = new CodeAttributeDeclaration(
                        cop.TypeString, aa);
                    if (cop.ParameterCount == 0)
                    {
                        AttributeConstructor ac = cop.Value as AttributeConstructor;
                        if (ac != null && ac.Values != null)
                        {
                            IList <CodeAttributeArgument> lst = ac.CreatePropertyExpressions();
                            foreach (CodeAttributeArgument caa in lst)
                            {
                                a.Arguments.Add(caa);
                            }
                        }
                        bool isInterface       = (holder is InterfaceClass);
                        bool isServiceContract = cop.BaseClassType.FullName.StartsWith("System.ServiceModel.ServiceContractAttribute", StringComparison.Ordinal);
                        if (isInterface && isServiceContract)
                        {
                            bool hasNamespace = false;
                            if (ac != null && ac.Values != null)
                            {
                                if (string.IsNullOrEmpty(ac.Values[PROP_Namespace] as string))
                                {
                                }
                                else
                                {
                                    hasNamespace = true;
                                }
                            }
                            if (!hasNamespace)
                            {
                                a.Arguments.Add(new CodeAttributeArgument(PROP_Namespace, new CodePrimitiveExpression(string.Format(CultureInfo.InvariantCulture, "http://{0}", namespaceText))));
                            }
                        }
                    }

                    attributs.Add(a);
                }
            }
        }
예제 #2
0
        protected override IObservable <float> CreateObservable(IAttributeHolder holder)
        {
            Ensure.That(holder, nameof(holder)).IsNotNull();

            return(_value.CombineLatest(OnModifierChange, OnRangeChange, (v, m, r) => r.Clamp(v * m)));
        }
예제 #3
0
        public override void Initialize(IAttributeHolder holder)
        {
            Gate = _gate.Bind(v => this.FindAttribute(v, holder));

            base.Initialize(holder);
        }
예제 #4
0
 public virtual void Initialize(float time, IAttributeHolder owner)
 {
     this.time  = Random.Range(0, 1000) * time;
     this.owner = owner;
 }