コード例 #1
0
 public FieldViewModel(IOptimizedPersistable parentObj, DataMember member, ObjectViewModel parentObject, SessionBase session)
   : base(parentObject, true)
 {
   _session = session;
   page = parentObj.Page;
   memberObj = member.GetMemberValue(parentObj.WrappedObject);
   isEncodedOidArray = (parentObj as BTreeNode) != null && memberObj != null && (memberObj as Array) != null && (member.Field.Name == "keysArray" || member.Field.Name == "valuesArray");
   fieldAsString = OptimizedPersistable.ToStringDetails(member, parentObj.WrappedObject, parentObj, parentObj.Page, true);
 }
コード例 #2
0
			protected override void OnValueChanged(DataMember element, Type oldValue, Type newValue)
			{
				base.OnValueChanged(element, oldValue, newValue);
				Type type = typeof(Collection<>).GetGenericArguments()[0];
				if (element.collectionTypePropertyStorage == type)
				{
					element.collectionTypePropertyStorage = element.collectionTypePropertyStorage.MakeArrayType();
				}
			}
コード例 #3
0
		/// <summary>
		/// Constructs the AggegateSelectField
		/// </summary>
		/// <param name="dataValue">
		/// DataMember for build the field definition
		/// </param>
		/// <param name="alias">
		/// Alias name of the resulting field
		/// </param>
		public SelectMember(DataMember member, string alias)
		{
			if (member == null)
			{
				throw new ArgumentNullException("member");
			}

			DataMember = member;
			Alias = alias;
		}
		private void RemoveDataElement(Store store, LinkedElementCollection<DataMember> dataElements, DataMember dataElement)
		{
			if(dataElement != null)
			{
				using(Transaction transaction = store.TransactionManager.BeginTransaction())
				{
					dataElements.Remove(dataElement);
					transaction.Commit();
				}
			}		
		}
コード例 #5
0
 public FieldViewModel(IOptimizedPersistable parentObj, DataMember member, ObjectViewModel parentObject, SessionBase session)
   : base(parentObject, true)
 {
   m_member = member;
   m_session = session;
   m_parentId = parentObj.Id; 
   object memberObj = member.GetMemberValue(parentObj.WrappedObject);
   m_isEncodedOidArray = (parentObj as BTreeNode) != null && memberObj != null && (memberObj as Array) != null && (member.Field.Name == "keysArray" || member.Field.Name == "valuesArray");
   m_isEncodedOidArray = m_isEncodedOidArray || parentObj.GetType().IsGenericType && parentObj.GetType().GetGenericTypeDefinition() == typeof(WeakReferenceList<>);
   m_fieldAsString = Utilities.ToStringDetails(member, parentObj.WrappedObject, parentObj, parentObj.Page, true);
 }
コード例 #6
0
 void LoadChild(DataMember member, object memberObj)
 {
     bool listWithItems = false;
     if (member.Field != null && member.Field.FieldType.IsGenericType && member.Field.FieldType.GetGenericTypeDefinition() == typeof(List<>))
     {
       IList list = (IList)memberObj;
       listWithItems = list != null && list.Count > 0;
     }
     if (member.Field != null && memberObj != null & (member.Field.FieldType.IsArray || member.HasId || listWithItems))
       base.Children.Add(new FieldViewModel(_object, member, this, _session));
     else
       base.Children.Add(new FieldViewModelNoExpansions(_object, member, this, _session));
 }
コード例 #7
0
 public FieldViewModelNoExpansions(IOptimizedPersistable parentObj, DataMember member, ObjectViewModel parentView, SessionBase session)
   : base(parentView, true)
 {
   fieldAsString = Utilities.ToStringDetails(member, parentObj.WrappedObject, parentObj, parentObj.Page, true);
 }
コード例 #8
0
		/// <summary>
		/// Constructs the AggegateSelectField
		/// </summary>
		/// <param name="dataValue">
		/// DataMember for build the field definition
		/// </param>
		/// <param name="aggregateFunction">
		/// Aggregate function to use for calculate the column
		/// </param>
		/// <param name="distinct">
		/// Speficy if the DISTINCT modifier must be applied
		/// </param>
		/// <param name="alias">
		/// Alias name of the resulting field
		/// </param>
		public SelectAggregateMember(DataMember member, SelectAggregateFunction aggregateFunction, string alias, bool distinct): base(member, alias)
		{
			AggregateFunction = aggregateFunction;
			Distinct = distinct;
		}
コード例 #9
0
ファイル: PlugManager.cs プロジェクト: cybord/Cosmos
        public MethodBase ResolvePlug(Type aTargetType, List <Type> aImpls, MethodBase aMethod, Type[] aParamTypes)
        {
            //TODO: This method is "reversed" from old - remember that when porting
            MethodBase xResult = null;

            // Setup param types for search
            Type[] xParamTypes;
            if (aMethod.IsStatic)
            {
                xParamTypes = aParamTypes;
            }
            else
            {
                // If its an instance method, we have to add this to the ParamTypes to search
                xParamTypes = new Type[aParamTypes.Length + 1];
                if (aParamTypes.Length > 0)
                {
                    aParamTypes.CopyTo(xParamTypes, 1);
                }
                xParamTypes[0] = aTargetType;
            }

            PlugMethodAttribute xAttrib = null;

            foreach (var xImpl in aImpls)
            {
                // TODO: cleanup this loop, next statement shouldnt be neccessary
                if (xResult != null)
                {
                    break;
                }
                // Plugs methods must be static, and public
                // Search for non signature matches first since signature searches are slower
                xResult = xImpl.GetMethod(aMethod.Name, BindingFlags.Static | BindingFlags.Public
                                          , null, xParamTypes, null);
                if (xResult == null && aMethod.Name == ".ctor")
                {
                    xResult = xImpl.GetMethod("Ctor", BindingFlags.Static | BindingFlags.Public
                                              , null, xParamTypes, null);
                }
                if (xResult == null && aMethod.Name == ".cctor")
                {
                    xResult = xImpl.GetMethod("CCtor", BindingFlags.Static | BindingFlags.Public
                                              , null, xParamTypes, null);
                }

                if (xResult == null)
                {
                    // Search by signature
                    foreach (var xSigMethod in xImpl.GetMethods(BindingFlags.Static | BindingFlags.Public))
                    {
                        // TODO: Only allow one, but this code for now takes the last one
                        // if there is more than one
                        xAttrib = null;
                        foreach (PlugMethodAttribute x in xSigMethod.GetCustomAttributes(typeof(PlugMethodAttribute), false))
                        {
                            xAttrib = x;
                        }

                        if (xAttrib != null && (xAttrib.IsWildcard && !xAttrib.WildcardMatchParameters))
                        {
                            MethodBase xTargetMethod = null;
                            if (String.Compare(xSigMethod.Name, "Ctor", true) == 0 ||
                                String.Compare(xSigMethod.Name, "Cctor", true) == 0)
                            {
                                xTargetMethod = aTargetType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance).SingleOrDefault();
                            }
                            else
                            {
                                xTargetMethod = (from item in aTargetType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)
                                                 where item.Name == xSigMethod.Name
                                                 select item).SingleOrDefault();
                            }
                            if (xTargetMethod == aMethod)
                            {
                                xResult = xSigMethod;
                            }
                        }
                        else
                        {
                            var xParams = xSigMethod.GetParameters();
                            //TODO: Static method plugs dont seem to be separated
                            // from instance ones, so the only way seems to be to try
                            // to match instance first, and if no match try static.
                            // I really don't like this and feel we need to find
                            // an explicit way to determine or mark the method
                            // implementations.
                            //
                            // Plug implementations take "this" as first argument
                            // so when matching we don't include it in the search
                            Type[] xTypesInst        = null;
                            var    xActualParamCount = xParams.Length;
                            foreach (var xParam in xParams)
                            {
                                if (xParam.GetCustomAttributes(typeof(FieldAccessAttribute), false).Length > 0)
                                {
                                    xActualParamCount--;
                                }
                            }
                            Type[] xTypesStatic = new Type[xActualParamCount];
                            // If 0 params, has to be a static plug so we skip
                            // any copying and leave xTypesInst = null
                            // If 1 params, xTypesInst must be converted to Type[0]
                            if (xActualParamCount == 1)
                            {
                                xTypesInst = new Type[0];

                                var xReplaceType = xParams[0].GetCustomAttributes(typeof(FieldTypeAttribute), false);
                                if (xReplaceType.Length == 1)
                                {
                                    xTypesStatic[0] = Type.GetType(((FieldTypeAttribute)xReplaceType[0]).Name, true);
                                }
                                else
                                {
                                    xTypesStatic[0] = xParams[0].ParameterType;
                                }
                            }
                            else if (xActualParamCount > 1)
                            {
                                xTypesInst = new Type[xActualParamCount - 1];
                                var xCurIdx = 0;
                                foreach (var xParam in xParams.Skip(1))
                                {
                                    if (xParam.GetCustomAttributes(typeof(FieldAccessAttribute), false).Length > 0)
                                    {
                                        continue;
                                    }

                                    var xReplaceType = xParam.GetCustomAttributes(typeof(FieldTypeAttribute), false);
                                    if (xReplaceType.Length == 1)
                                    {
                                        xTypesInst[xCurIdx] = Type.GetType(((FieldTypeAttribute)xReplaceType[0]).Name, true);
                                    }
                                    else
                                    {
                                        xTypesInst[xCurIdx] = xParam.ParameterType;
                                    }

                                    xCurIdx++;
                                }
                                xCurIdx = 0;
                                foreach (var xParam in xParams)
                                {
                                    if (xParam.GetCustomAttributes(typeof(FieldAccessAttribute), false).Length > 0)
                                    {
                                        xCurIdx++;
                                        continue;
                                    }
                                    if (xCurIdx >= xTypesStatic.Length)
                                    {
                                        break;
                                    }
                                    xTypesStatic[xCurIdx] = xParam.ParameterType;
                                    xCurIdx++;
                                }
                            }
                            SysReflection.MethodBase xTargetMethod = null;
                            // TODO: In future make rule that all ctor plugs are called
                            // ctor by name, or use a new attrib
                            //TODO: Document all the plug stuff in a document on website
                            //TODO: To make inclusion of plugs easy, we can make a plugs master
                            // that references the other default plugs so user exes only
                            // need to reference that one.
                            // TODO: Skip FieldAccessAttribute if in impl
                            if (xTypesInst != null)
                            {
                                if (string.Compare(xSigMethod.Name, "ctor", true) == 0)
                                {
                                    xTargetMethod = aTargetType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, CallingConventions.Any, xTypesInst, null);
                                }
                                else
                                {
                                    xTargetMethod = aTargetType.GetMethod(xSigMethod.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, CallingConventions.Any, xTypesInst, null);
                                }
                            }
                            // Not an instance method, try static
                            if (xTargetMethod == null)
                            {
                                if (string.Compare(xSigMethod.Name, "cctor", true) == 0 ||
                                    string.Compare(xSigMethod.Name, "ctor", true) == 0)
                                {
                                    xTargetMethod = aTargetType.GetConstructor(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, CallingConventions.Any, xTypesStatic, null);
                                }
                                else
                                {
                                    xTargetMethod = aTargetType.GetMethod(xSigMethod.Name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, CallingConventions.Any, xTypesStatic, null);
                                }
                            }
                            if (xTargetMethod == aMethod)
                            {
                                xResult = xSigMethod;
                                break;
                            }
                            if (xAttrib != null && xAttrib.Signature != null)
                            {
                                var xName = DataMember.FilterStringForIncorrectChars(LabelName.GenerateFullName(aMethod));
                                if (string.Compare(xName, xAttrib.Signature, true) == 0)
                                {
                                    xResult = xSigMethod;
                                    break;
                                }
                            }
                            xAttrib = null;
                        }
                    }
                }
                else
                {
                    // check if signatur is equal
                    var xResPara     = xResult.GetParameters();
                    var xAMethodPara = aMethod.GetParameters();
                    if (aMethod.IsStatic)
                    {
                        if (xResPara.Length != xAMethodPara.Length)
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        if (xResPara.Length - 1 != xAMethodPara.Length)
                        {
                            return(null);
                        }
                    }
                    for (int i = 0; i < xAMethodPara.Length; i++)
                    {
                        int correctIndex = aMethod.IsStatic ? i : i + 1;
                        if (xResPara[correctIndex].ParameterType != xAMethodPara[i].ParameterType)
                        {
                            return(null);
                        }
                    }
                    if (xResult.Name == "Ctor" && aMethod.Name == ".ctor")
                    {
                    }
                    else if (xResult.Name == "CCtor" && aMethod.Name == ".cctor")
                    {
                    }
                    else if (xResult.Name != aMethod.Name)
                    {
                        return(null);
                    }
                }
            }
            if (xResult == null)
            {
                return(null);
            }

            // If we found a matching method, check for attributes
            // that might disable it.
            //TODO: For signature ones, we could cache the attrib. Thats
            // why we check for null here
            if (xAttrib == null)
            {
                // TODO: Only allow one, but this code for now takes the last one
                // if there is more than one
                foreach (PlugMethodAttribute x in xResult.GetCustomAttributes(typeof(PlugMethodAttribute), false))
                {
                    xAttrib = x;
                }
            }

            // See if we need to disable this plug
            if (xAttrib != null)
            {
                if (!xAttrib.Enabled)
                {
                    //xResult = null;
                    return(null);
                }
                else if (xAttrib.IsMonoOnly)
                {
                    //TODO: Check this against build options
                    //TODO: Two exclusive IsOnly's dont make sense
                    // refactor these as a positive rather than negative
                    // Same thing at type plug level
                    //xResult = null;
                    return(null);
                }
                //else if (xAttrib.Signature != null) {
                //  var xName = DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GenerateFullName(xResult));
                //  if (string.Compare(xName, xAttrib.Signature, true) != 0) {
                //    xResult = null;
                //  }
                //}
            }

            InlineAttribute xInlineAttrib = null;

            foreach (InlineAttribute inli in xResult.GetCustomAttributes(typeof(InlineAttribute), false))
            {
                xInlineAttrib = inli;
            }

            if (xInlineAttrib == null)
            {
                if (Queue != null)
                {
                    CompilerHelpers.Debug("Queueing Plug:", xResult.DeclaringType, "::", xResult.Name);
                    Queue(xResult, null, "Plug Method");
                }
            }

            //if (xAttrib != null && xAttrib.Signature != null)
            //{
            //    var xTargetMethods = aTargetType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            //    //System_Void__Indy_IL2CPU_Assembler_Assembler__cctor__
            //    //If signature exists, the search is slow. Signatures
            //    //are infrequent though, so for now we just go slow method
            //    //and have not optimized or cached this info. When we
            //    //redo the plugs, we can fix this.
            //    bool xEnabled=true;
            //    foreach (var xTargetMethod in xTargetMethods)
            //    {
            //        string sName = DataMember.FilterStringForIncorrectChars(MethodInfoLabelGenerator.GenerateFullName(xTargetMethod));
            //        if (string.Compare(sName, xAttrib.Signature, true) == 0)
            //        {
            //            //uint xUID = QueueMethod(xPlugImpl.Plug, "Plug", xMethod, true);
            //            //mMethodPlugs.Add(xTargetMethod, new PlugInfo(xUID, xAttrib.Assembler));
            //            // Mark as disabled, because we already handled it
            //            xEnabled = false;
            //            break;
            //        }
            //    }
            //    // if still enabled, we didn't find our method
            //    if (xEnabled)
            //    {
            //        // todo: more precise error: imagine having a 100K line project, and this error happens...
            //        throw new Exception("Plug target method not found.");
            //    }
            //}
            return(xResult);
        }
コード例 #10
0
		public ValueCompareFilter(DataMember member, IComparable valueToCompare, CompareOperator compareOperator)
		{
			Member = member;
			ValueToCompare = valueToCompare;
			Operator = compareOperator;
		}
コード例 #11
0
		/// <summary>
		/// Constructs the AggegateSelectField
		/// </summary>
		/// <param name="dataValue">
		/// DataMember for build the field definition
		/// </param>
		/// <param name="aggregateFunction">
		/// Aggregate function to use for calculate the column
		/// </param>
		public SelectAggregateMember(DataMember member, SelectAggregateFunction aggregateFunction) : this(member, aggregateFunction, string.Empty) { }
コード例 #12
0
		/// <summary>
		/// Constructs the AggegateSelectField
		/// </summary>
		/// <param name="dataValue">
		/// DataMember for build the field definition
		/// </param>
		public SelectMember(DataMember member): this(member, null)
		{ 
		}
コード例 #13
0
ファイル: Utilities.cs プロジェクト: VelocityDB/VelocityDB
 /// <summary>
 /// This is a support function for the VelocityDbBrowser. It converts a field into a string.
 /// </summary>
 /// <param name="member">A field in an object</param>
 /// <param name="obj">The object containing the field</param>
 /// <param name="pObj">The object containing the field or the owner of the object containing the field</param>
 /// <param name="page">The page of the object</param>
 /// <param name="skipArrays">Option to skip arrays of the object</param>
 /// <returns></returns>
 public static string ToStringDetails(DataMember member, object obj, IOptimizedPersistable pObj, Page page, bool skipArrays)
 {
   SessionBase session = pObj.Page.Database.Session;
   IOptimizedPersistable placeHolder;
   Schema schema = session.OpenSchema(false);
   FieldInfo field = member.Field;
   object o = member.GetMemberValue(obj);
   if (member.IsGuid)
   {
     Guid guid = (Guid)o;
     return guid.ToString();
   }
   StringBuilder sb = new StringBuilder(100);
   if (o == null)
     sb.Append("  " + member.FieldName + " : " + "null");
   else
   {
     bool foundIt = session.GlobalObjWrapperGet(o, out placeHolder);
     if (foundIt)
       sb.Append("  " + member.FieldName + " : " + placeHolder.WrappedObject.ToString() + " " + Oid.AsString(placeHolder.Id));
     else
     {
       Array array = o as Array;
       if (array != null)
       {
         sb.Append("  " + member.FieldName + " " + field.FieldType.ToGenericTypeString() + " size: " + array.Length.ToString());
         if (!skipArrays)
           sb.Append(ArrayToString(array, false, page));
       }
       else
       {
         IList list = o as IList;
         if (list != null)
         {
           int i = 0;
           string listObjStr = "  " + member.FieldName + " " + o.GetType().ToGenericTypeString() + " size: " + list.Count.ToString();
           sb.Append(listObjStr);
           if (!skipArrays)
             foreach (object listObj in list)
             {
               sb.AppendLine();
               pObj = listObj as OptimizedPersistable;
               if (listObj != null && pObj != null)
                 sb.Append("\t[" + i.ToString() + "]\t" + Oid.AsString(pObj.Id));
               else
               {
                 foundIt = session.GlobalObjWrapperGet(listObj, out placeHolder);
                 if (foundIt)
                   sb.Append("\t[" + i.ToString() + "]\t" + Oid.AsString(placeHolder.Id));
                 else
                   sb.Append("\t[" + i.ToString() + "]\t" + listObj.ToString());
               }
               i++;
             }
         }
         else
         {
           VelocityDbType t = null;
           if (field.FieldType == CommonTypes.s_typeOfType)
           {
             Type fieldType = o as Type;
             sb.Append("  " + field.Name + " : " + fieldType.ToGenericTypeString());
           }
           else
           {
             bool cond1 = field.FieldType.GetTypeInfo().IsPrimitive || member.HasId || field.FieldType == CommonTypes.s_typeOfString || field.FieldType.GetTypeInfo().IsEnum;
             if (cond1 || schema.LookupByType.TryGetValue(field.FieldType, out t) == false ||
               (field.FieldType.GetTypeInfo().IsGenericType && field.FieldType.GetGenericTypeDefinition() == CommonTypes.s_typeOfWeakIOptimizedPersistableReference))
               sb.Append("  " + field.Name + " : " + o.ToString());
             else
             {
               TypeVersion memberShape = t.LastShape();
               sb.Append("  " + field.Name + " : " + ToStringDetails(o, schema, page, memberShape, skipArrays));
             }
           }
         }
       }
     }
   }
   return sb.ToString();
 }
コード例 #14
0
ファイル: Ldsfld.cs プロジェクト: omnislash321/Cosmos
        public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
        {
            var xType   = aMethod.MethodBase.DeclaringType;
            var xOpCode = (ILOpCodes.OpField)aOpCode;

            SysReflection.FieldInfo xField = xOpCode.Value;

            // call cctor:
            var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();

            if (xCctor != null)
            {
                new CPUx86.Call {
                    DestinationLabel = LabelName.Get(xCctor)
                };
                ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
                new Label(".AfterCCTorExceptionCheck");
            }

            //Assembler.Stack.Pop();
            //int aExtraOffset;// = 0;
            //bool xNeedsGC = xField.FieldType.IsClass && !xField.FieldType.IsValueType;
            var xSize = SizeOfType(xField.FieldType);
            //if( xNeedsGC )
            //{
            //    aExtraOffset = 12;
            //}

            string xDataName = DataMember.GetStaticFieldName(xField);

            if (xSize >= 4)
            {
                for (int i = 1; i <= (xSize / 4); i++)
                {
                    //	Pop("eax");
                    //	Move(Assembler, "dword [" + mDataName + " + 0x" + (i * 4).ToString("X") + "]", "eax");
                    new CPUx86.Push {
                        DestinationRef = Cosmos.Assembler.ElementReference.New(xDataName), DestinationIsIndirect = true, DestinationDisplacement = ( int )(xSize - (i * 4))
                    };
                }
                switch (xSize % 4)
                {
                case 1:
                {
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.EAX, SourceValue = 0
                    };
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.AL, SourceRef = Cosmos.Assembler.ElementReference.New(xDataName), SourceIsIndirect = true
                    };
                    new CPUx86.Push {
                        DestinationReg = CPUx86.Registers.EAX
                    };
                    break;
                }

                case 2:
                {
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.EAX, SourceValue = 0
                    };
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.AX, SourceRef = Cosmos.Assembler.ElementReference.New(xDataName), SourceIsIndirect = true
                    };
                    new CPUx86.Push {
                        DestinationReg = CPUx86.Registers.EAX
                    };
                    break;
                }

                case 0:
                {
                    break;
                }

                default:
                    //EmitNotImplementedException( Assembler, GetServiceProvider(), "Ldsfld: Remainder size " + ( xSize % 4 ) + " not supported!", mCurLabel, mMethodInformation, mCurOffset, mNextLabel );
                    throw new NotImplementedException();
                    //break;
                }
            }
            else
            {
                switch (xSize)
                {
                case 1:
                {
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.EAX, SourceValue = 0
                    };
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.AL, SourceRef = Cosmos.Assembler.ElementReference.New(xDataName), SourceIsIndirect = true
                    };
                    new CPUx86.Push {
                        DestinationReg = CPUx86.Registers.EAX
                    };
                    break;
                }

                case 2:
                {
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.EAX, SourceValue = 0
                    };
                    new CPUx86.Mov {
                        DestinationReg = CPUx86.Registers.AX, SourceRef = Cosmos.Assembler.ElementReference.New(xDataName), SourceIsIndirect = true
                    };
                    new CPUx86.Push {
                        DestinationReg = CPUx86.Registers.EAX
                    };
                    break;
                }

                case 0:
                {
                    break;
                }

                default:
                    //EmitNotImplementedException( Assembler, GetServiceProvider(), "Ldsfld: Remainder size " + ( xSize % 4 ) + " not supported!", mCurLabel, mMethodInformation, mCurOffset, mNextLabel );
                    throw new NotImplementedException();
                    //break;
                }
            }
        }
コード例 #15
0
 internal DataMemberInstance(CustomReportItem owner, DataMember memberDef)
     : base(memberDef.ReportScope)
 {
     m_owner     = owner;
     m_memberDef = memberDef;
 }
コード例 #16
0
ファイル: ILOp.cs プロジェクト: tgiphil/IL2CPU
 public static string GetTypeIDLabel(Type aType)
 {
     return("VMT__TYPE_ID_HOLDER__" + DataMember.FilterStringForIncorrectChars(LabelName.GetFullName(aType) + " ASM_IS__" + aType.Assembly.GetName().Name));
 }
コード例 #17
0
        public void AllSupported()
        {
            UInt64          id;
            AllSupported    allSuported, allSupported2;
            AllSuportedSub1 allSuportedSub1, allSuportedSub2;
            AllSuportedSub2 allSuportedSub2_1, allSuportedSub2_2;
            AllSuportedSub3 allSuportedSub3_1, allSuportedSub3_2;
            AllSuportedSub4 allSuportedSub4;

            AllSupported[,] a1              = new AllSupported[10, 5];
            AllSupported[,,] a2             = new AllSupported[8, 4, 3];
            AllSupported[,,,] a3            = new AllSupported[7, 6, 2, 1];
            Dictionary <int, string>[,,] a4 = new Dictionary <int, string> [2, 4, 33];
            string s1str = DataMember.TypeToString(a1.GetType());
            string s2str = DataMember.TypeToString(a2.GetType());
            string s3str = DataMember.TypeToString(a3.GetType());
            string s4str = DataMember.TypeToString(a4.GetType());
            bool   typeUpdated;

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                Type t1 = DataMember.StringToType(s1str, session, out typeUpdated);
                Type t2 = DataMember.StringToType(s2str, session, out typeUpdated);
                Type t3 = DataMember.StringToType(s3str, session, out typeUpdated);
                Type t4 = DataMember.StringToType(s4str, session, out typeUpdated);
                Assert.AreEqual(t1, a1.GetType());
                Assert.AreEqual(t2, a2.GetType());
                Assert.AreEqual(t3, a3.GetType());
                Assert.AreEqual(t4, a4.GetType());
                allSuportedSub4 = new AllSuportedSub4();
                session.Persist(allSuportedSub4);
                id = allSuportedSub4.Id;
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                allSuportedSub4 = (AllSuportedSub4)session.Open(id);
                Assert.NotNull(allSuportedSub4);
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                allSuportedSub1 = new AllSuportedSub1(3);
                allSuportedSub1.Persist(session, allSuportedSub1);
                foreach (var o in allSuportedSub1.PetListOidShort)
                {
                    session.Persist(o, allSuportedSub1);
                }
                id = allSuportedSub1.Id;
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                allSuportedSub2 = (AllSuportedSub1)session.Open(id);
                Assert.NotNull(allSuportedSub2);
                Assert.AreEqual(allSuportedSub2.m_type[0], typeof(Pet));
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                allSuportedSub2_1 = new AllSuportedSub2(3);
                allSuportedSub2_1.Persist(session, allSuportedSub2_1);
                id = allSuportedSub2_1.Id;
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                allSuportedSub2_2 = (AllSuportedSub2)session.Open(id);
                Assert.NotNull(allSuportedSub2_2);
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                allSuportedSub3_1 = new AllSuportedSub3(3);
                allSuportedSub3_1.Persist(session, allSuportedSub3_1);
                id = allSuportedSub3_1.Id;
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                allSuportedSub3_2 = (AllSuportedSub3)session.Open(id);
                Assert.NotNull(allSuportedSub3_2);
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                var x = new AllSuportedSub5();
                session.Persist(x);
                id = x.Id;
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                var x = (AllSuportedSub5)session.Open(id);
                x.Update();
                x.nullableaDouble = 0.5;
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                var x = new AllSuportedSub6();
                session.Persist(x);
                id = x.Id;
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                var x = (AllSuportedSub6)session.Open(id);
                x.Update();
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                allSuported = new AllSupported(3);
                allSuported.Persist(session, allSuported);
                allSuported.m_weakRefArray[0] = new WeakIOptimizedPersistableReference <IOptimizedPersistable>(allSuported);
                allSuported.m_objectArray[0]  = new WeakIOptimizedPersistableReference <IOptimizedPersistable>(allSuported);
                id = allSuported.Id;
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                allSupported2 = (AllSupported)session.Open(id);
                allSupported2.Update();
                allSupported2.nullableaDouble  = 0.5;
                allSupported2.NullableDateTime = DateTime.MaxValue;
                allSupported2 = null;
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                allSupported2 = (AllSupported)session.Open(id);
                Assert.NotNull(allSupported2);
                Assert.AreEqual(allSupported2.nullableaDouble, 0.5);
                Assert.AreEqual(allSupported2.NullableDateTime, DateTime.MaxValue);
                session.Commit();
                session.BeginUpdate();
                allSupported2.NullableDateTime = DateTime.UtcNow;

                session.Commit();
                session.BeginRead();
                allSupported2 = (AllSupported)session.Open(id);
                Assert.AreEqual(DateTimeKind.Utc, allSupported2.NullableDateTime.Value.Kind);
                session.Commit();
            }
        }
コード例 #18
0
 public DataMemberInstance(CustomReportItem owner, DataMember memberDef)
     : base(memberDef.ReportScope)
 {
     this.m_owner     = owner;
     this.m_memberDef = memberDef;
 }
コード例 #19
0
ファイル: Stsfld.cs プロジェクト: invisal/Cosmos
        public override void Execute(_MethodInfo aMethod, ILOpCode aOpCode)
        {
            var       xType            = aMethod.MethodBase.DeclaringType;
            var       xOpCode          = (ILOpCodes.OpField)aOpCode;
            FieldInfo xField           = xOpCode.Value;
            var       xIsReferenceType = TypeIsReferenceType(xField.FieldType);

            // call cctor:
            var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();

            if (xCctor != null && xCctor.DeclaringType != aMethod.MethodBase.DeclaringType)
            {
                XS.Call(LabelName.Get(xCctor));
                ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
                XS.Label(".AfterCCTorExceptionCheck");
            }

            //int aExtraOffset;// = 0;
            //bool xNeedsGC = xField.FieldType.IsClass && !xField.FieldType.IsValueType;
            uint xSize = SizeOfType(xField.FieldType);

            //if( xNeedsGC )
            //{
            //    aExtraOffset = 12;
            //}
            new Comment(Assembler, "Type = '" + xField.FieldType.FullName /*+ "', NeedsGC = " + xNeedsGC*/);

            uint xOffset = 0;

            var xFields = xField.DeclaringType.GetFields();

            foreach (FieldInfo xInfo in xFields)
            {
                if (xInfo == xField)
                {
                    break;
                }

                xOffset += SizeOfType(xInfo.FieldType);
            }
            string xDataName = DataMember.GetStaticFieldName(xField);

            if (xIsReferenceType)
            {
                XS.Add(XSRegisters.ESP, 4);
                XS.Pop(XSRegisters.EAX);
                XS.Set(ElementReference.New(xDataName).Name, XSRegisters.EAX, destinationIsIndirect: true, destinationDisplacement: 4);
                return;
            }
            for (int i = 0; i < (xSize / 4); i++)
            {
                XS.Pop(XSRegisters.EAX);
                new CPUx86.Mov {
                    DestinationRef = ElementReference.New(xDataName, i * 4), DestinationIsIndirect = true, SourceReg = CPUx86.RegistersEnum.EAX
                };
            }
            switch (xSize % 4)
            {
            case 1:
            {
                XS.Pop(XSRegisters.EAX);
                new CPUx86.Mov {
                    DestinationRef = ElementReference.New(xDataName, (int)((xSize / 4) * 4)), DestinationIsIndirect = true, SourceReg = CPUx86.RegistersEnum.AL
                };
                break;
            }

            case 2:
            {
                XS.Pop(XSRegisters.EAX);
                new CPUx86.Mov {
                    DestinationRef = Cosmos.Assembler.ElementReference.New(xDataName, (int)((xSize / 4) * 4)), DestinationIsIndirect = true, SourceReg = CPUx86.RegistersEnum.AX
                };
                break;
            }

            case 0:
            {
                break;
            }

            default:
                //EmitNotImplementedException(Assembler, GetServiceProvider(), "Ldsfld: Remainder size " + (xSize % 4) + " not supported!", mCurLabel, mMethodInformation, mCurOffset, mNextLabel);
                throw new NotImplementedException();
                //break;
            }
        }
コード例 #20
0
            private int WriteMembers(ClassDataContract classContract, LocalBuilder extensionDataLocal, ClassDataContract derivedMostClassContract)
            {
                int memberCount = (classContract.BaseContract == null) ? 0 :
                                  WriteMembers(classContract.BaseContract, extensionDataLocal, derivedMostClassContract);

                int classMemberCount = classContract.Members.Count;

                _ilg.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.IncrementItemCountMethod, classMemberCount);

                for (int i = 0; i < classMemberCount; i++, memberCount++)
                {
                    DataMember   member      = classContract.Members[i];
                    Type         memberType  = member.MemberType;
                    LocalBuilder memberValue = null;

                    _ilg.Load(_contextArg);
                    _ilg.Call(methodInfo: member.IsGetOnlyCollection ?
                              XmlFormatGeneratorStatics.StoreIsGetOnlyCollectionMethod :
                              XmlFormatGeneratorStatics.ResetIsGetOnlyCollectionMethod);

                    if (!member.EmitDefaultValue)
                    {
                        memberValue = LoadMemberValue(member);
                        _ilg.IfNotDefaultValue(memberValue);
                    }

                    bool requiresNameAttribute = DataContractJsonSerializerImpl.CheckIfXmlNameRequiresMapping(classContract.MemberNames[i]);
                    if (requiresNameAttribute || !TryWritePrimitive(memberType, memberValue, member.MemberInfo, arrayItemIndex: null, name: null, nameIndex: i + _childElementIndex))
                    {
                        // Note: DataContractSerializer has member-conflict logic here to deal with the schema export
                        //       requirement that the same member can't be of two different types.
                        if (requiresNameAttribute)
                        {
                            _ilg.Call(thisObj: null, JsonFormatGeneratorStatics.WriteJsonNameWithMappingMethod, _xmlWriterArg, _memberNamesArg, i + _childElementIndex);
                        }
                        else
                        {
                            WriteStartElement(nameLocal: null, nameIndex: i + _childElementIndex);
                        }
                        if (memberValue == null)
                        {
                            memberValue = LoadMemberValue(member);
                        }
                        WriteValue(memberValue);
                        WriteEndElement();
                    }

                    if (classContract.HasExtensionData)
                    {
                        _ilg.Call(thisObj: _contextArg, XmlFormatGeneratorStatics.WriteExtensionDataMethod, _xmlWriterArg, extensionDataLocal, memberCount);
                    }

                    if (!member.EmitDefaultValue)
                    {
                        if (member.IsRequired)
                        {
                            _ilg.Else();
                            _ilg.Call(thisObj: null, XmlFormatGeneratorStatics.ThrowRequiredMemberMustBeEmittedMethod, member.Name, classContract.UnderlyingType);
                        }
                        _ilg.EndIf();
                    }
                }

                _typeIndex++;
                _childElementIndex += classMemberCount;
                return(memberCount);
            }
コード例 #21
0
		object LoadMemberValue (DataMember member)
		{
			return CodeInterpreter.GetMember (member.MemberInfo, objLocal);
		}
コード例 #22
0
        public void EmitDataWithConv(string name, object value, MemberSpec v, bool constant = false, bool verbatim = false, bool isglobal = false)
        {
            DataMember dm;

            if (value is string)
            {
                if (constant)
                {
                    dm = new DataMember(name, value.ToString(), true, verbatim)
                    {
                        IsGlobal = isglobal
                    }
                }
                ;
                else
                {
                    dm = new DataMember(name, value.ToString(), false, verbatim)
                    {
                        IsGlobal = isglobal
                    }
                };
            }
            else if (value is float)
            {
                dm = new DataMember(name, BitConverter.GetBytes((float)value))
                {
                    IsGlobal = isglobal
                }
            }
            ;
            else if (value is byte[])
            {
                dm = new DataMember(name, (byte[])value)
                {
                    IsGlobal = isglobal
                }
            }
            ;
            else if (value is bool)
            {
                dm = new DataMember(name, ((bool)value) ? (new byte[1] {
                    EmitContext.TRUE
                }) : (new byte[1] {
                    0
                }))
                {
                    IsGlobal = isglobal
                }
            }
            ;
            else if (value is byte)
            {
                dm = new DataMember(name, new byte[1] {
                    (byte)value
                })
                {
                    IsGlobal = isglobal
                }
            }
            ;
            else if (value is ushort)
            {
                dm = new DataMember(name, new ushort[1] {
                    (ushort)value
                })
                {
                    IsGlobal = isglobal
                }
            }
            ;
            else
            {
                dm = new DataMember(name, new object[1] {
                    value
                })
                {
                    IsGlobal = isglobal
                }
            };

            EmitData(dm, v, constant);
        }

        EmitContext()
        {
            _names = new List <string>();
        }
コード例 #23
0
        public IPersistable CreateRIFObject(ObjectType objectType, ref IntermediateFormatReader context)
        {
            IPersistable persistable = null;

            if (objectType == ObjectType.Null)
            {
                return(null);
            }
            IDOwner    parentIDOwner    = m_parentIDOwner;
            ReportItem parentReportItem = m_parentReportItem;

            switch (objectType)
            {
            case ObjectType.PageSection:
                persistable        = new PageSection(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.Line:
                persistable        = new Line(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.Rectangle:
                persistable        = new Rectangle(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.Image:
                persistable        = new Image(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.TextBox:
                persistable        = new TextBox(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.SubReport:
                persistable        = new SubReport(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.Grouping:
                persistable = new Grouping(ConstructionPhase.Deserializing);
                break;

            case ObjectType.Sorting:
                persistable = new Sorting(ConstructionPhase.Deserializing);
                break;

            case ObjectType.ReportItemCollection:
                persistable = new ReportItemCollection();
                break;

            case ObjectType.ReportItemIndexer:
                persistable = default(ReportItemIndexer);
                break;

            case ObjectType.Style:
                persistable = new Style(ConstructionPhase.Deserializing);
                break;

            case ObjectType.AttributeInfo:
                persistable = new AttributeInfo();
                break;

            case ObjectType.Visibility:
                persistable = new Visibility();
                break;

            case ObjectType.ExpressionInfo:
                persistable = new ExpressionInfo();
                break;

            case ObjectType.ExpressionInfoTypeValuePair:
                persistable = new ExpressionInfoTypeValuePair();
                break;

            case ObjectType.DataAggregateInfo:
                persistable = new DataAggregateInfo();
                break;

            case ObjectType.RunningValueInfo:
                persistable = new RunningValueInfo();
                break;

            case ObjectType.Filter:
                persistable = new Filter();
                break;

            case ObjectType.DataSource:
                persistable = new DataSource();
                break;

            case ObjectType.DataSet:
                persistable = new DataSet();
                break;

            case ObjectType.ReportQuery:
                persistable = new ReportQuery();
                break;

            case ObjectType.Field:
                persistable = new Field();
                break;

            case ObjectType.ParameterValue:
                persistable = new ParameterValue();
                break;

            case ObjectType.ReportSnapshot:
                persistable = new ReportSnapshot();
                break;

            case ObjectType.DocumentMapNode:
                persistable = new DocumentMapNode();
                break;

            case ObjectType.DocumentMapBeginContainer:
                persistable = DocumentMapBeginContainer.Instance;
                break;

            case ObjectType.DocumentMapEndContainer:
                persistable = DocumentMapEndContainer.Instance;
                break;

            case ObjectType.ReportInstance:
                persistable = new ReportInstance();
                break;

            case ObjectType.ParameterInfo:
                persistable = new ParameterInfo();
                break;

            case ObjectType.ValidValue:
                persistable = new ValidValue();
                break;

            case ObjectType.ParameterDataSource:
                persistable = new ParameterDataSource();
                break;

            case ObjectType.ParameterDef:
                persistable = new ParameterDef();
                break;

            case ObjectType.ProcessingMessage:
                persistable = new ProcessingMessage();
                break;

            case ObjectType.CodeClass:
                persistable = default(CodeClass);
                break;

            case ObjectType.Action:
                persistable = new Action();
                break;

            case ObjectType.RenderingPagesRanges:
                persistable = default(RenderingPagesRanges);
                break;

            case ObjectType.IntermediateFormatVersion:
                persistable = new IntermediateFormatVersion();
                break;

            case ObjectType.ImageInfo:
                persistable = new ImageInfo();
                break;

            case ObjectType.ActionItem:
                persistable = new ActionItem();
                break;

            case ObjectType.DataValue:
                persistable = new DataValue();
                break;

            case ObjectType.CustomReportItem:
                persistable        = new CustomReportItem(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.SortFilterEventInfoMap:
                persistable = new SortFilterEventInfoMap();
                break;

            case ObjectType.SortFilterEventInfo:
                persistable = new SortFilterEventInfo();
                break;

            case ObjectType.EndUserSort:
                persistable = new EndUserSort();
                break;

            case ObjectType.ScopeLookupTable:
                persistable = new ScopeLookupTable();
                break;

            case ObjectType.Tablix:
                persistable        = new Tablix(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.TablixHeader:
                persistable = new TablixHeader();
                break;

            case ObjectType.TablixMember:
                persistable = new TablixMember();
                break;

            case ObjectType.TablixColumn:
                persistable = new TablixColumn();
                break;

            case ObjectType.TablixRow:
                persistable = new TablixRow();
                break;

            case ObjectType.TablixCornerCell:
                persistable = new TablixCornerCell();
                break;

            case ObjectType.TablixCell:
                persistable = new TablixCell();
                break;

            case ObjectType.Chart:
                persistable        = new Chart(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.ChartMember:
                persistable = new ChartMember();
                break;

            case ObjectType.ChartSeries:
                persistable = new ChartSeries();
                break;

            case ObjectType.ChartDataPoint:
                persistable = new ChartDataPoint();
                break;

            case ObjectType.ChartDataPointValues:
                persistable = new ChartDataPointValues();
                break;

            case ObjectType.ChartArea:
                persistable = new ChartArea();
                break;

            case ObjectType.ChartLegend:
                persistable = new ChartLegend();
                break;

            case ObjectType.ChartLegendTitle:
                persistable = new ChartLegendTitle();
                break;

            case ObjectType.ChartAxis:
                persistable = new ChartAxis();
                break;

            case ObjectType.ThreeDProperties:
                persistable = new ChartThreeDProperties();
                break;

            case ObjectType.ChartDataLabel:
                persistable = new ChartDataLabel();
                break;

            case ObjectType.ChartMarker:
                persistable = new ChartMarker();
                break;

            case ObjectType.ChartTitle:
                persistable = new ChartTitle();
                break;

            case ObjectType.ChartAxisScaleBreak:
                persistable = new ChartAxisScaleBreak();
                break;

            case ObjectType.ChartDerivedSeries:
                persistable = new ChartDerivedSeries();
                break;

            case ObjectType.ChartBorderSkin:
                persistable = new ChartBorderSkin();
                break;

            case ObjectType.ChartNoDataMessage:
                persistable = new ChartNoDataMessage();
                break;

            case ObjectType.ChartItemInLegend:
                persistable = new ChartItemInLegend();
                break;

            case ObjectType.ChartEmptyPoints:
                persistable = new ChartEmptyPoints();
                break;

            case ObjectType.ChartNoMoveDirections:
                persistable = new ChartNoMoveDirections();
                break;

            case ObjectType.ChartFormulaParameter:
                persistable = new ChartFormulaParameter();
                break;

            case ObjectType.ChartLegendColumn:
                persistable = new ChartLegendColumn();
                break;

            case ObjectType.ChartLegendColumnHeader:
                persistable = new ChartLegendColumnHeader();
                break;

            case ObjectType.ChartLegendCustomItem:
                persistable = new ChartLegendCustomItem();
                break;

            case ObjectType.ChartLegendCustomItemCell:
                persistable = new ChartLegendCustomItemCell();
                break;

            case ObjectType.ChartAlignType:
                persistable = new ChartAlignType();
                break;

            case ObjectType.ChartElementPosition:
                persistable = new ChartElementPosition();
                break;

            case ObjectType.ChartSmartLabel:
                persistable = new ChartSmartLabel();
                break;

            case ObjectType.ChartStripLine:
                persistable = new ChartStripLine();
                break;

            case ObjectType.ChartAxisTitle:
                persistable = new ChartAxisTitle();
                break;

            case ObjectType.ChartCustomPaletteColor:
                persistable = new ChartCustomPaletteColor();
                break;

            case ObjectType.GridLines:
                persistable = new ChartGridLines();
                break;

            case ObjectType.ChartTickMarks:
                persistable = new ChartTickMarks();
                break;

            case ObjectType.DataMember:
                persistable = new DataMember();
                break;

            case ObjectType.CustomDataRow:
                persistable = new CustomDataRow();
                break;

            case ObjectType.DataCell:
                persistable = new DataCell();
                break;

            case ObjectType.Variable:
                persistable = new Variable();
                break;

            case ObjectType.Page:
                persistable = new Page();
                break;

            case ObjectType.Paragraph:
                persistable = new Paragraph();
                break;

            case ObjectType.TextRun:
                persistable = new TextRun();
                break;

            case ObjectType.Report:
                persistable        = new Report(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.GaugePanel:
                persistable        = new GaugePanel(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.GaugeMember:
                persistable = new GaugeMember();
                break;

            case ObjectType.GaugeRow:
                persistable = new GaugeRow();
                break;

            case ObjectType.GaugeCell:
                persistable = new GaugeCell();
                break;

            case ObjectType.BackFrame:
                persistable = new BackFrame();
                break;

            case ObjectType.CapImage:
                persistable = new CapImage();
                break;

            case ObjectType.FrameBackground:
                persistable = new FrameBackground();
                break;

            case ObjectType.FrameImage:
                persistable = new FrameImage();
                break;

            case ObjectType.CustomLabel:
                persistable = new CustomLabel();
                break;

            case ObjectType.GaugeImage:
                persistable = new GaugeImage();
                break;

            case ObjectType.GaugeInputValue:
                persistable = new GaugeInputValue();
                break;

            case ObjectType.GaugeLabel:
                persistable = new GaugeLabel();
                break;

            case ObjectType.GaugePanelItem:
                persistable = new GaugePanelItem();
                break;

            case ObjectType.GaugeTickMarks:
                persistable = new GaugeTickMarks();
                break;

            case ObjectType.LinearGauge:
                persistable = new LinearGauge();
                break;

            case ObjectType.LinearPointer:
                persistable = new LinearPointer();
                break;

            case ObjectType.LinearScale:
                persistable = new LinearScale();
                break;

            case ObjectType.NumericIndicator:
                persistable = new NumericIndicator();
                break;

            case ObjectType.PinLabel:
                persistable = new PinLabel();
                break;

            case ObjectType.PointerCap:
                persistable = new PointerCap();
                break;

            case ObjectType.PointerImage:
                persistable = new PointerImage();
                break;

            case ObjectType.RadialGauge:
                persistable = new RadialGauge();
                break;

            case ObjectType.RadialPointer:
                persistable = new RadialPointer();
                break;

            case ObjectType.RadialScale:
                persistable = new RadialScale();
                break;

            case ObjectType.ScaleLabels:
                persistable = new ScaleLabels();
                break;

            case ObjectType.ScalePin:
                persistable = new ScalePin();
                break;

            case ObjectType.ScaleRange:
                persistable = new ScaleRange();
                break;

            case ObjectType.IndicatorImage:
                persistable = new IndicatorImage();
                break;

            case ObjectType.StateIndicator:
                persistable = new StateIndicator();
                break;

            case ObjectType.Thermometer:
                persistable = new Thermometer();
                break;

            case ObjectType.TickMarkStyle:
                persistable = new TickMarkStyle();
                break;

            case ObjectType.TopImage:
                persistable = new TopImage();
                break;

            case ObjectType.LookupInfo:
                persistable = new LookupInfo();
                break;

            case ObjectType.LookupDestinationInfo:
                persistable = new LookupDestinationInfo();
                break;

            case ObjectType.ReportSection:
                persistable = new ReportSection();
                break;

            case ObjectType.MapFieldDefinition:
                persistable = new MapFieldDefinition();
                break;

            case ObjectType.MapFieldName:
                persistable = new MapFieldName();
                break;

            case ObjectType.MapLineLayer:
                persistable = new MapLineLayer();
                break;

            case ObjectType.MapShapefile:
                persistable = new MapShapefile();
                break;

            case ObjectType.MapPolygonLayer:
                persistable = new MapPolygonLayer();
                break;

            case ObjectType.MapSpatialDataRegion:
                persistable = new MapSpatialDataRegion();
                break;

            case ObjectType.MapSpatialDataSet:
                persistable = new MapSpatialDataSet();
                break;

            case ObjectType.MapPointLayer:
                persistable = new MapPointLayer();
                break;

            case ObjectType.MapTile:
                persistable = new MapTile();
                break;

            case ObjectType.MapTileLayer:
                persistable = new MapTileLayer();
                break;

            case ObjectType.MapField:
                persistable = new MapField();
                break;

            case ObjectType.MapLine:
                persistable = new MapLine();
                break;

            case ObjectType.MapPolygon:
                persistable = new MapPolygon();
                break;

            case ObjectType.MapPoint:
                persistable = new MapPoint();
                break;

            case ObjectType.MapLineTemplate:
                persistable = new MapLineTemplate();
                break;

            case ObjectType.MapPolygonTemplate:
                persistable = new MapPolygonTemplate();
                break;

            case ObjectType.MapMarkerTemplate:
                persistable = new MapMarkerTemplate();
                break;

            case ObjectType.Map:
                persistable        = new Map(m_parentReportItem);
                m_parentReportItem = (ReportItem)persistable;
                break;

            case ObjectType.MapBorderSkin:
                persistable = new MapBorderSkin();
                break;

            case ObjectType.MapDataRegion:
                persistable = new MapDataRegion(m_parentReportItem);
                break;

            case ObjectType.MapMember:
                persistable = new MapMember();
                break;

            case ObjectType.MapRow:
                persistable = new MapRow();
                break;

            case ObjectType.MapCell:
                persistable = new MapCell();
                break;

            case ObjectType.MapLocation:
                persistable = new MapLocation();
                break;

            case ObjectType.MapSize:
                persistable = new MapSize();
                break;

            case ObjectType.MapGridLines:
                persistable = new MapGridLines();
                break;

            case ObjectType.MapBindingFieldPair:
                persistable = new MapBindingFieldPair();
                break;

            case ObjectType.MapCustomView:
                persistable = new MapCustomView();
                break;

            case ObjectType.MapDataBoundView:
                persistable = new MapDataBoundView();
                break;

            case ObjectType.MapElementView:
                persistable = new MapElementView();
                break;

            case ObjectType.MapViewport:
                persistable = new MapViewport();
                break;

            case ObjectType.MapLimits:
                persistable = new MapLimits();
                break;

            case ObjectType.MapColorScale:
                persistable = new MapColorScale();
                break;

            case ObjectType.MapColorScaleTitle:
                persistable = new MapColorScaleTitle();
                break;

            case ObjectType.MapDistanceScale:
                persistable = new MapDistanceScale();
                break;

            case ObjectType.MapTitle:
                persistable = new MapTitle();
                break;

            case ObjectType.MapLegend:
                persistable = new MapLegend();
                break;

            case ObjectType.MapLegendTitle:
                persistable = new MapLegendTitle();
                break;

            case ObjectType.MapBucket:
                persistable = new MapBucket();
                break;

            case ObjectType.MapColorPaletteRule:
                persistable = new MapColorPaletteRule();
                break;

            case ObjectType.MapColorRangeRule:
                persistable = new MapColorRangeRule();
                break;

            case ObjectType.MapCustomColorRule:
                persistable = new MapCustomColorRule();
                break;

            case ObjectType.MapCustomColor:
                persistable = new MapCustomColor();
                break;

            case ObjectType.MapLineRules:
                persistable = new MapLineRules();
                break;

            case ObjectType.MapPolygonRules:
                persistable = new MapPolygonRules();
                break;

            case ObjectType.MapSizeRule:
                persistable = new MapSizeRule();
                break;

            case ObjectType.MapMarkerImage:
                persistable = new MapMarkerImage();
                break;

            case ObjectType.MapMarker:
                persistable = new MapMarker();
                break;

            case ObjectType.MapMarkerRule:
                persistable = new MapMarkerRule();
                break;

            case ObjectType.MapPointRules:
                persistable = new MapPointRules();
                break;

            case ObjectType.PageBreak:
                persistable = new PageBreak();
                break;

            case ObjectType.DataScopeInfo:
                persistable = new DataScopeInfo();
                break;

            case ObjectType.LinearJoinInfo:
                persistable = new LinearJoinInfo();
                break;

            case ObjectType.IntersectJoinInfo:
                persistable = new IntersectJoinInfo();
                break;

            case ObjectType.BucketedDataAggregateInfos:
                persistable = new BucketedDataAggregateInfos();
                break;

            case ObjectType.DataAggregateInfoBucket:
                persistable = new DataAggregateInfoBucket();
                break;

            case ObjectType.NumericIndicatorRange:
                persistable = new NumericIndicatorRange();
                break;

            case ObjectType.IndicatorState:
                persistable = new IndicatorState();
                break;

            case ObjectType.SharedDataSetQuery:
                persistable = new SharedDataSetQuery();
                break;

            case ObjectType.DataSetCore:
                persistable = new DataSetCore();
                break;

            case ObjectType.DataSetParameterValue:
                persistable = new DataSetParameterValue();
                break;

            case ObjectType.RIFVariantContainer:
                persistable = new RIFVariantContainer();
                break;

            case ObjectType.IdcRelationship:
                persistable = new IdcRelationship();
                break;

            case ObjectType.DefaultRelationship:
                persistable = new DefaultRelationship();
                break;

            case ObjectType.JoinCondition:
                persistable = new Relationship.JoinCondition();
                break;

            case ObjectType.BandLayoutOptions:
                persistable = new BandLayoutOptions();
                break;

            case ObjectType.LabelData:
                persistable = new LabelData();
                break;

            case ObjectType.Slider:
                persistable = new Slider();
                break;

            case ObjectType.Coverflow:
                persistable = new Coverflow();
                break;

            case ObjectType.PlayAxis:
                persistable = new PlayAxis();
                break;

            case ObjectType.BandNavigationCell:
                persistable = new BandNavigationCell();
                break;

            case ObjectType.Tabstrip:
                persistable = new Tabstrip();
                break;

            case ObjectType.NavigationItem:
                persistable = new NavigationItem();
                break;

            case ObjectType.ScopedFieldInfo:
                persistable = new ScopedFieldInfo();
                break;

            default:
                Global.Tracer.Assert(condition: false, "Unsupported object type: " + objectType);
                break;
            }
            IDOwner iDOwner = persistable as IDOwner;

            if (iDOwner != null)
            {
                iDOwner.ParentInstancePath = m_parentIDOwner;
                m_parentIDOwner            = iDOwner;
            }
            persistable.Deserialize(context);
            m_parentIDOwner    = parentIDOwner;
            m_parentReportItem = parentReportItem;
            return(persistable);
        }
コード例 #24
0
 public virtual void Visit(DataMember dataMember)
 {
 }
コード例 #25
0
        /// <summary>
        /// This is a support function for the VelocityDbBrowser. It converts a field into a string.
        /// </summary>
        /// <param name="member">A field in an object</param>
        /// <param name="obj">The object containing the field</param>
        /// <param name="pObj">The object containing the field or the owner of the object containing the field</param>
        /// <param name="page">The page of the object</param>
        /// <param name="skipArrays">Option to skip arrays of the object</param>
        /// <returns></returns>
        public static string ToStringDetails(DataMember member, object obj, IOptimizedPersistable pObj, Page page, bool skipArrays)
        {
            SessionBase           session = pObj.Page.Database.Session;
            IOptimizedPersistable placeHolder;
            Schema    schema = session.OpenSchema(false);
            FieldInfo field  = member.Field;
            object    o      = member.GetMemberValue(obj);

            if (member.IsGuid)
            {
                Guid guid = (Guid)o;
                return(guid.ToString());
            }
            StringBuilder sb = new StringBuilder(100);

            if (o == null)
            {
                sb.Append("  " + member.FieldName + " : " + "null");
            }
            else
            {
                bool foundIt = session.GlobalObjWrapperGet(o, out placeHolder);
                if (foundIt)
                {
                    sb.Append("  " + member.FieldName + " : " + placeHolder.WrappedObject.ToString() + " " + Oid.AsString(placeHolder.Id));
                }
                else
                {
                    Array array = o as Array;
                    if (array != null)
                    {
                        sb.Append("  " + member.FieldName + " " + field.FieldType.ToGenericTypeString() + " size: " + array.Length.ToString());
                        if (!skipArrays)
                        {
                            sb.Append(ArrayToString(array, false, page));
                        }
                    }
                    else
                    {
                        IList list = o as IList;
                        if (list != null)
                        {
                            int    i          = 0;
                            string listObjStr = "  " + member.FieldName + " " + o.GetType().ToGenericTypeString() + " size: " + list.Count.ToString();
                            sb.Append(listObjStr);
                            if (!skipArrays)
                            {
                                foreach (object listObj in list)
                                {
                                    sb.AppendLine();
                                    pObj = listObj as OptimizedPersistable;
                                    if (listObj != null && pObj != null)
                                    {
                                        sb.Append("\t[" + i.ToString() + "]\t" + Oid.AsString(pObj.Id));
                                    }
                                    else
                                    {
                                        foundIt = session.GlobalObjWrapperGet(listObj, out placeHolder);
                                        if (foundIt)
                                        {
                                            sb.Append("\t[" + i.ToString() + "]\t" + Oid.AsString(placeHolder.Id));
                                        }
                                        else
                                        {
                                            sb.Append("\t[" + i.ToString() + "]\t" + listObj.ToString());
                                        }
                                    }
                                    i++;
                                }
                            }
                        }
                        else
                        {
                            VelocityDbType t = null;
                            if (field.FieldType == CommonTypes.s_typeOfType)
                            {
                                Type fieldType = o as Type;
                                sb.Append("  " + field.Name + " : " + fieldType.ToGenericTypeString());
                            }
                            else
                            {
                                bool cond1 = field.FieldType.GetTypeInfo().IsPrimitive || member.HasId || field.FieldType == CommonTypes.s_typeOfString || field.FieldType.GetTypeInfo().IsEnum;
                                if (cond1 || schema.LookupByType.TryGetValue(field.FieldType, out t) == false ||
                                    (field.FieldType.GetTypeInfo().IsGenericType&& field.FieldType.GetGenericTypeDefinition() == CommonTypes.s_typeOfWeakIOptimizedPersistableReference))
                                {
                                    sb.Append("  " + field.Name + " : " + o.ToString());
                                }
                                else
                                {
                                    TypeVersion memberShape = t.LastShape();
                                    sb.Append("  " + field.Name + " : " + ToStringDetails(o, schema, page, memberShape, skipArrays));
                                }
                            }
                        }
                    }
                }
            }
            return(sb.ToString());
        }
コード例 #26
0
ファイル: Select.cs プロジェクト: gitter-badger/OKHOSTING.ORM
        public void AddMember(string memberExpression)
        {
            //if this is a native datamember, just add a SelectMember
            if (DataType.IsMapped(memberExpression))
            {
                DataMember dmember = DataType[memberExpression];

                //this is a native member of this dataType
                SelectMember sm = new SelectMember(dmember, dmember.Member.Expression.Replace('.', '_'));
                Members.Add(sm);

                //finish iteration here
                return;
            }

            //see if this is a dataMember from a base type
            foreach (DataType parent in DataType.BaseDataTypes.Skip(1))
            {
                if (!parent.IsMapped(memberExpression))
                {
                    continue;
                }

                //if this is a native datamember, just add a SelectMember
                DataMember dmember = parent[memberExpression];

                //create join for child-parent relationship
                SelectJoin join = Joins.Where(j => j.Type == parent && j.Alias == parent.Name + "_base").SingleOrDefault();

                if (join == null)
                {
                    join          = new SelectJoin();
                    join.JoinType = SelectJoinType.Inner;
                    join.Type     = parent;
                    join.Alias    = parent.Name + "_base";

                    var childPK = DataType.PrimaryKey.ToList();
                    var joinPK  = join.Type.PrimaryKey.ToList();

                    for (int y = 0; y < joinPK.Count; y++)
                    {
                        //DataMember pk in join.Type.PrimaryKey
                        var filter = new Filters.MemberCompareFilter()
                        {
                            Member                   = childPK[y],
                            MemberToCompare          = joinPK[y],
                            MemberToCompareTypeAlias = join.Alias,
                        };

                        join.On.Add(filter);
                    }

                    Joins.Add(join);
                }

                //this is a native member of this dataType
                SelectMember sm = new SelectMember(dmember, dmember.Member.Expression.Replace('.', '_'));
                join.Members.Add(sm);

                //finish iteration here
                return;
            }


            //if the expression was not found as a single datamember, split it in nested members
            List <System.Reflection.MemberInfo> nestedMemberInfos = MemberExpression.GetMemberInfos(DataType.InnerType, memberExpression).ToList();

            //check every part of the expression
            for (int i = 0; i < nestedMemberInfos.Count; i++)
            {
                System.Reflection.MemberInfo memberInfo = nestedMemberInfos[i];
                bool   isTheFirstOne     = i == 0;
                bool   isTheLastOne      = i == nestedMemberInfos.Count - 1;
                string currentExpression = string.Empty;

                for (int y = 0; y <= i; y++)
                {
                    currentExpression += '.' + nestedMemberInfos[y].Name;
                }

                currentExpression = currentExpression.Trim('.');

                //if this is a dataMember from a base type, create join for that relationship
                foreach (DataType parent in DataType.BaseDataTypes)
                {
                    DataType referencingDataType = isTheFirstOne ? parent : MemberExpression.GetReturnType(nestedMemberInfos[i - 1]);

                    //if this is not a native or inherited DataMember, so we must detect the nested members and create the respective joins
                    if (!isTheLastOne && DataType.IsMapped(MemberExpression.GetReturnType(memberInfo)))
                    {
                        DataType foreignDataType    = MemberExpression.GetReturnType(memberInfo);
                        bool     foreignKeyIsMapped = true;

                        foreach (DataMember foreignKey in foreignDataType.PrimaryKey)
                        {
                            DataMember localKey = referencingDataType.DataMembers.Where(m => m.Member.Expression == memberInfo.Name + "." + foreignKey.Member).SingleOrDefault();

                            if (localKey == null)
                            {
                                foreignKeyIsMapped = false;
                            }
                        }

                        if (foreignKeyIsMapped)
                        {
                            SelectJoin foreignJoin = Joins.Where(j => j.Type == foreignDataType && j.Alias == currentExpression.Replace('.', '_')).SingleOrDefault();

                            if (foreignJoin == null)
                            {
                                foreignJoin          = new SelectJoin();
                                foreignJoin.JoinType = SelectJoinType.Left;
                                foreignJoin.Type     = foreignDataType;
                                foreignJoin.Alias    = currentExpression.Replace('.', '_');

                                string previousJoinAlias = string.Empty;

                                if (isTheFirstOne && parent != DataType)
                                {
                                    previousJoinAlias = parent.Name + "_base";
                                }
                                else
                                {
                                    for (int y = 0; y <= i - 1; y++)
                                    {
                                        previousJoinAlias += '.' + nestedMemberInfos[y].Name;
                                    }

                                    previousJoinAlias = previousJoinAlias.Trim('.');
                                }

                                foreach (DataMember foreignKey in foreignDataType.PrimaryKey)
                                {
                                    DataMember localKey = referencingDataType.DataMembers.Where(m => m.Member.Expression == memberInfo.Name + "." + foreignKey.Member).SingleOrDefault();

                                    var filter = new Filters.MemberCompareFilter()
                                    {
                                        Member                   = localKey,
                                        MemberToCompare          = foreignKey,
                                        TypeAlias                = previousJoinAlias,
                                        MemberToCompareTypeAlias = foreignJoin.Alias,
                                    };

                                    foreignJoin.On.Add(filter);
                                }

                                Joins.Add(foreignJoin);
                            }

                            break;
                        }
                    }

                    if (!isTheFirstOne && isTheLastOne)
                    {
                        DataMember   dmember     = referencingDataType[memberInfo.Name];
                        SelectJoin   foreignJoin = Joins.Where(j => j.Type == referencingDataType && j.Alias == currentExpression.Replace("." + memberInfo.Name, string.Empty).Replace('.', '_')).SingleOrDefault();
                        SelectMember sm          = new SelectMember(dmember, currentExpression.Replace('.', '_'));
                        foreignJoin.Members.Add(sm);

                        break;
                    }
                }
            }
        }
コード例 #27
0
		public ValueCompareFilter(DataMember member, IComparable valueToCompare): this(member, valueToCompare, CompareOperator.Equal)
		{
		}
コード例 #28
0
ファイル: LikeFilter.cs プロジェクト: okhosting/OKHOSTING.ORM
		public LikeFilter(DataMember member, string pattern): this(member, pattern, false)
		{
		}
コード例 #29
0
		/// <summary>
		/// Constructs the AggegateSelectField
		/// </summary>
		/// <param name="dataValue">
		/// DataMember for build the field definition
		/// </param>
		public SelectAggregateMember(DataMember member): this(member, SelectAggregateFunction.None) 
		{ 
		}
コード例 #30
0
ファイル: Select.cs プロジェクト: gitter-badger/OKHOSTING.ORM
 public void AddMember(DataMember dataMember)
 {
     AddMember(dataMember.Member.Expression);
 }
コード例 #31
0
		/// <summary>
		/// Constructs the AggegateSelectField
		/// </summary>
		/// <param name="dataValue">
		/// DataMember for build the field definition
		/// </param>
		/// <param name="aggregateFunction">
		/// Aggregate function to use for calculate the column
		/// </param>
		/// <param name="alias">
		/// Alias name of the resulting field
		/// </param>
		public SelectAggregateMember(DataMember member, SelectAggregateFunction aggregateFunction, string alias) : this(member, aggregateFunction, alias, false) { }
コード例 #32
0
 private void OnChangeMember(DataMember mem, bool isCalc)
 {
     // event
     this.OnBeforeChange(this);
 }
コード例 #33
0
		/// <summary>
		/// Constructor
		/// Creates a DataContractHasDataMembers link in the same Partition as the given DataContract
		/// </summary>
		/// <param name="source">DataContract to use as the source of the relationship.</param>
		/// <param name="target">DataMember to use as the target of the relationship.</param>
		public DataContractHasDataMembers(DataContract source, DataMember target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(DataContractHasDataMembers.DataContractDomainRoleId, source), new DslModeling::RoleAssignment(DataContractHasDataMembers.DataMemberDomainRoleId, target)}, null)
		{
		}
コード例 #34
0
 public FieldViewModelNoExpansions(IOptimizedPersistable parentObj, DataMember member, ObjectViewModel parentView, SessionBase session)
     : base(parentView, true)
 {
     fieldAsString = OptimizedPersistable.ToStringDetails(member, parentObj.WrappedObject, parentObj, parentObj.Page, true);
 }
コード例 #35
0
		public RangeFilter(DataMember member, IComparable minValue, IComparable maxValue)
		{
			Member = member;
			MinValue = minValue;
			MaxValue = maxValue;
		}
コード例 #36
0
		public static DataContract GetDataContract(DataMember element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, DataMemberDomainRoleId) as DataContract;
		}
コード例 #37
0
ファイル: LikeFilter.cs プロジェクト: okhosting/OKHOSTING.ORM
		public LikeFilter(DataMember member, string pattern, bool caseSensitive)
		{
			Member = member;
			Pattern = pattern;
			CaseSensitive = caseSensitive;
		}
コード例 #38
0
		public static void SetDataContract(DataMember element, DataContract newDataContract)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, DataMemberDomainRoleId, newDataContract);
		}
コード例 #39
0
        private void OnAddMember(DataMember mem, bool isCalc)
        {
            // event
            this.OnBeforeChange(this);

            // check filter hier
            if(this.Axis.Ordinal==2)
            {
                if(mem is Set)
                    throw new Exception("Set of members cannot act as filter, please use aggregate instead");

                if(_filterMember!=null && _filterMember.UniqueName!=mem.UniqueName)
                    this.RemoveMember(_filterMember);
                _filterMember=mem;
            }
        }
コード例 #40
0
		/// <summary>
		/// Creates a new instance
		/// </summary>
		public OrderBy(DataMember orderBy): this(orderBy, SortDirection.Ascending)
		{
		}
コード例 #41
0
        private void OnRemoveMember(DataMember mem, bool isCalc)
        {
            // event
            this.OnBeforeChange(this);

            //zero order tuple member out
            if(mem.UniqueName==this.OrderTupleMember)
                this.OrderTupleMember=null;

            // if datamember has been deleted on filter axis, there's no datamember anymore (it can be only one)
            if(this.Axis.Ordinal==2 && _filterMember!=null && _filterMember.UniqueName==mem.UniqueName)
                _filterMember=null;
        }
コード例 #42
0
		/// <summary>
		/// Creates a new instance
		/// </summary>
		public OrderBy(DataMember member, SortDirection direction)
		{
			this.Member = member;
			this.Direction = direction;
		}
コード例 #43
0
ファイル: AppAssembler.cs プロジェクト: vogon101/Cosmos
        protected void MethodBegin(MethodInfo aMethod)
        {
            new Comment("---------------------------------------------------------");
            new Comment("Assembly: " + aMethod.MethodBase.DeclaringType.Assembly.FullName);
            new Comment("Type: " + aMethod.MethodBase.DeclaringType.ToString());
            new Comment("Name: " + aMethod.MethodBase.Name);
            new Comment("Plugged: " + (aMethod.PlugMethod == null ? "No" : "Yes"));
            // for now:
            var shouldIncludeArgAndLocalsComment = true;
            if (shouldIncludeArgAndLocalsComment)
            {
                if (aMethod.MethodAssembler == null && !aMethod.IsInlineAssembler)
                {
                    // the body of aMethod is getting emitted
                    var xBody = aMethod.MethodBase.GetMethodBody();
                    if (xBody != null)
                    {
                        foreach (var localVariable in xBody.LocalVariables)
                        {
                            new Comment(String.Format("Local {0} at EBP-{1}", localVariable.LocalIndex, ILOp.GetEBPOffsetForLocal(aMethod, localVariable.LocalIndex)));
                        }
                    }
                    var xIdxOffset = 0u;
                    if (!aMethod.MethodBase.IsStatic)
                    {
                        new Comment(String.Format("Argument[0] $this at EBP+{0}, size = {1}", X86.IL.Ldarg.GetArgumentDisplacement(aMethod, 0), ILOp.Align(ILOp.SizeOfType(aMethod.MethodBase.DeclaringType), 4)));
                        xIdxOffset++;
                    }

                    var xParams = aMethod.MethodBase.GetParameters();
                    var xParamCount = (ushort)xParams.Length;

                    for (ushort i = 0; i < xParamCount; i++)
                    {
                        var xOffset = X86.IL.Ldarg.GetArgumentDisplacement(aMethod, (ushort)(i + xIdxOffset));
                        var xSize = X86.IL.Ldarg.SizeOfType(xParams[i].ParameterType);
                        // if last argument is 8 byte long, we need to add 4, so that debugger could read all 8 bytes from this variable in positiv direction
                        new Comment(String.Format("Argument[{3}] {0} at EBP+{1}, size = {2}", xParams[i].Name, xOffset, xSize, (xIdxOffset + i)));
                    }

                    var xMethodInfo = aMethod.MethodBase as SysReflection.MethodInfo;
                    if (xMethodInfo != null)
                    {
                        var xSize = ILOp.Align(ILOp.SizeOfType(xMethodInfo.ReturnType), 4);
                        new Comment(String.Format("Return size: {0}", xSize));
                    }
                }
            }

            // Issue label that is used for calls etc.
            string xMethodLabel;
            if (aMethod.PluggedMethod != null)
            {
                xMethodLabel = "PLUG_FOR___" + LabelName.Get(aMethod.PluggedMethod.MethodBase);
            }
            else
            {
                xMethodLabel = LabelName.Get(aMethod.MethodBase);
            }
            new Cosmos.Assembler.Label(xMethodLabel);
            //Assembler.WriteDebugVideo("Method " + aMethod.UID);

            // We could use same GUID as MethodLabelStart, but its better to keep GUIDs unique globaly for items
            // so during debugging they can never be confused as to what they point to.
            mCurrentMethodGuid = DebugInfo.CreateId();

            // We issue a second label for GUID. This is increases label count, but for now we need a master label first.
            // We issue a GUID label to reduce amount of work and time needed to construct debugging DB.
            var xLabelGuid = DebugInfo.CreateId();
            new Cosmos.Assembler.Label("GUID_" + xLabelGuid.ToString());

            mCurrentMethodLabel = "METHOD_" + xLabelGuid.ToString();
            Cosmos.Assembler.Label.LastFullLabel = mCurrentMethodLabel;

            mCurrentMethodLabelEndGuid = DebugInfo.CreateId();

            if (aMethod.MethodBase.IsStatic && aMethod.MethodBase is ConstructorInfo)
            {
                new Comment("Static constructor. See if it has been called already, return if so.");
                var xName = DataMember.FilterStringForIncorrectChars("CCTOR_CALLED__" + LabelName.GetFullName(aMethod.MethodBase.DeclaringType));
                var xAsmMember = new DataMember(xName, (byte)0);
                Assembler.DataMembers.Add(xAsmMember);
                new Compare { DestinationRef = Cosmos.Assembler.ElementReference.New(xName), DestinationIsIndirect = true, Size = 8, SourceValue = 1 };
                new ConditionalJump { Condition = ConditionalTestEnum.Equal, DestinationLabel = ".BeforeQuickReturn" };
                new Mov { DestinationRef = Cosmos.Assembler.ElementReference.New(xName), DestinationIsIndirect = true, Size = 8, SourceValue = 1 };
                new Jump { DestinationLabel = ".AfterCCTorAlreadyCalledCheck" };
                new Cosmos.Assembler.Label(".BeforeQuickReturn");
                new Mov { DestinationReg = RegistersEnum.ECX, SourceValue = 0 };
                new Return { };
                new Cosmos.Assembler.Label(".AfterCCTorAlreadyCalledCheck");
            }

            new Push { DestinationReg = Registers.EBP };
            new Mov { DestinationReg = Registers.EBP, SourceReg = Registers.ESP };

            if (DebugMode == DebugMode.Source)
            {
                // Would be nice to use xMethodSymbols.GetSourceStartEnd but we cant
                // because its not implemented by the unmanaged code underneath.
                //
                // This doesnt seem right to store as a field, but old code had it that way so we
                // continue using a field for now.
                mSequences = DebugInfo.GetSequencePoints(aMethod.MethodBase, true);
                if (mSequences.Length > 0)
                {
                    DebugInfo.AddDocument(mSequences[0].Document);

                    var xMethod = new Method()
                    {
                        ID = mCurrentMethodGuid,
                        TypeToken = aMethod.MethodBase.DeclaringType.MetadataToken,
                        MethodToken = aMethod.MethodBase.MetadataToken,

                        LabelStartID = xLabelGuid,
                        LabelEndID = mCurrentMethodLabelEndGuid,
                        LabelCall = xMethodLabel,

                        AssemblyFileID = DebugInfo.AssemblyGUIDs[aMethod.MethodBase.DeclaringType.Assembly],
                        DocumentID = DebugInfo.DocumentGUIDs[mSequences[0].Document.ToLower()],

                        // Storing Line + Col as one item makes comparisons MUCH easier, otherwise we have to
                        // check for things like col < start col but line > start line.
                        //
                        // () around << are VERY important.. + has precedence over <<
                        LineColStart = ((Int64)mSequences[0].LineStart << 32) + mSequences[0].ColStart,
                        LineColEnd = ((Int64)(mSequences[mSequences.Length - 1].LineEnd) << 32) + mSequences[mSequences.Length - 1].ColEnd
                    };
                    DebugInfo.AddMethod(xMethod);
                }
            }

            if (aMethod.MethodAssembler == null && aMethod.PlugMethod == null && !aMethod.IsInlineAssembler)
            {
                // the body of aMethod is getting emitted
                var xBody = aMethod.MethodBase.GetMethodBody();
                if (xBody != null)
                {
                    var xLocalsOffset = mLocals_Arguments_Infos.Count;
                    aMethod.LocalVariablesSize = 0;
                    foreach (var xLocal in xBody.LocalVariables)
                    {
                        var xInfo = new LOCAL_ARGUMENT_INFO
                        {
                            METHODLABELNAME = xMethodLabel,
                            IsArgument = false,
                            INDEXINMETHOD = xLocal.LocalIndex,
                            NAME = "Local" + xLocal.LocalIndex,
                            OFFSET = 0 - (int)ILOp.GetEBPOffsetForLocalForDebugger(aMethod, xLocal.LocalIndex),
                            TYPENAME = xLocal.LocalType.AssemblyQualifiedName
                        };
                        mLocals_Arguments_Infos.Add(xInfo);

                        var xSize = ILOp.Align(ILOp.SizeOfType(xLocal.LocalType), 4);
                        new Comment(String.Format("Local {0}, Size {1}", xLocal.LocalIndex, xSize));
                        for (int i = 0; i < xSize / 4; i++)
                        {
                            new Push { DestinationValue = 0 };
                        }
                        aMethod.LocalVariablesSize += xSize;
                        //new Sub { DestinationReg = Registers.ESP, SourceValue = ILOp.Align(ILOp.SizeOfType(xLocal.LocalType), 4) };
                    }
                    var xCecilMethod = GetCecilMethodDefinitionForSymbolReading(aMethod.MethodBase);
                    if (xCecilMethod != null && xCecilMethod.Body != null)
                    {
                        // mLocals_Arguments_Infos is one huge list, so ourlatest additions are at the end
                        for (int i = 0; i < xCecilMethod.Body.Variables.Count; i++)
                        {
                            mLocals_Arguments_Infos[xLocalsOffset + i].NAME = xCecilMethod.Body.Variables[i].Name;
                        }
                        for (int i = xLocalsOffset + xCecilMethod.Body.Variables.Count - 1; i >= xLocalsOffset; i--)
                        {
                            if (mLocals_Arguments_Infos[i].NAME.Contains('$'))
                            {
                                mLocals_Arguments_Infos.RemoveAt(i);
                            }
                        }
                    }
                }

                // debug info:
                var xIdxOffset = 0u;
                if (!aMethod.MethodBase.IsStatic)
                {
                    mLocals_Arguments_Infos.Add(new LOCAL_ARGUMENT_INFO
                    {
                        METHODLABELNAME = xMethodLabel,
                        IsArgument = true,
                        NAME = "this:" + X86.IL.Ldarg.GetArgumentDisplacement(aMethod, 0),
                        INDEXINMETHOD = 0,
                        OFFSET = X86.IL.Ldarg.GetArgumentDisplacement(aMethod, 0),
                        TYPENAME = aMethod.MethodBase.DeclaringType.AssemblyQualifiedName
                    });

                    xIdxOffset++;
                }

                var xParams = aMethod.MethodBase.GetParameters();
                var xParamCount = (ushort)xParams.Length;

                for (ushort i = 0; i < xParamCount; i++)
                {
                    var xOffset = X86.IL.Ldarg.GetArgumentDisplacement(aMethod, (ushort)(i + xIdxOffset));
                    // if last argument is 8 byte long, we need to add 4, so that debugger could read all 8 bytes from this variable in positiv direction
                    xOffset -= (int)Cosmos.IL2CPU.ILOp.Align(ILOp.SizeOfType(xParams[i].ParameterType), 4) - 4;
                    mLocals_Arguments_Infos.Add(new LOCAL_ARGUMENT_INFO
                    {
                        METHODLABELNAME = xMethodLabel,
                        IsArgument = true,
                        INDEXINMETHOD = (int)(i + xIdxOffset),
                        NAME = xParams[i].Name,
                        OFFSET = xOffset,
                        TYPENAME = xParams[i].ParameterType.AssemblyQualifiedName
                    });
                }
            }
        }
 public void TestDoValidateCollectionItem(DataMember objectToValidate, object currentTarget, string key, ValidationResults validationResults)
 {
     DataContract contract = currentTarget as DataContract;
     foreach (DataMember element in contract.DataMembers)
     {
         this.DoValidateCollectionItem(element, currentTarget, key, validationResults);
     }
 }
コード例 #45
0
 private LocalBuilder LoadMemberValue(DataMember member)
 {
     ilg.LoadAddress(objectLocal);
     ilg.LoadMember(member.MemberInfo);
     LocalBuilder memberValue = ilg.DeclareLocal(member.MemberType, member.Name + "Value");
     ilg.Stloc(memberValue);
     return memberValue;
 }
コード例 #46
0
        protected override int ReflectionWriteMembers(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract classContract, ClassDataContract derivedMostClassContract, int childElementIndex, XmlDictionaryString[] memberNames)
        {
            int memberCount = (classContract.BaseContract == null) ? 0 :
                              ReflectionWriteMembers(xmlWriter, obj, context, classContract.BaseContract, derivedMostClassContract, childElementIndex, memberNames);

            childElementIndex += memberCount;

            Type classType = classContract.UnadaptedClassType;

            context.IncrementItemCount(classContract.Members.Count);
            for (int i = 0; i < classContract.Members.Count; i++, memberCount++)
            {
                DataMember member     = classContract.Members[i];
                Type       memberType = member.MemberType;
                if (member.IsGetOnlyCollection)
                {
                    context.StoreIsGetOnlyCollection();
                }


                bool   shouldWriteValue = true;
                object memberValue      = null;
                if (!member.EmitDefaultValue)
                {
                    memberValue = ReflectionGetMemberValue(obj, member);
                    object defaultValue = XmlFormatGeneratorStatics.GetDefaultValue(memberType);
                    if ((memberValue == null && defaultValue == null) ||
                        (memberValue != null && memberValue.Equals(defaultValue)))
                    {
                        shouldWriteValue = false;

                        if (member.IsRequired)
                        {
                            XmlObjectSerializerWriteContext.ThrowRequiredMemberMustBeEmitted(member.Name, classContract.UnderlyingType);
                        }
                    }
                }

                if (shouldWriteValue)
                {
                    if (memberValue == null)
                    {
                        memberValue = ReflectionGetMemberValue(obj, member);
                    }
                    bool requiresNameAttribute = DataContractJsonSerializerImpl.CheckIfXmlNameRequiresMapping(classContract.MemberNames[i]);
                    PrimitiveDataContract primitiveContract = member.MemberPrimitiveContract;
                    if (requiresNameAttribute || !ReflectionTryWritePrimitive(xmlWriter, context, memberType, memberValue, memberNames[i + childElementIndex] /*name*/, null /*ns*/, primitiveContract))
                    {
                        // Note: DataContractSerializer has member-conflict logic here to deal with the schema export
                        //       requirement that the same member can't be of two different types.
                        if (requiresNameAttribute)
                        {
                            XmlObjectSerializerWriteContextComplexJson.WriteJsonNameWithMapping(xmlWriter, memberNames, i + childElementIndex);
                        }
                        else
                        {
                            ReflectionWriteStartElement(xmlWriter, memberNames[i + childElementIndex]);
                        }

                        ReflectionWriteValue(xmlWriter, context, memberType, memberValue, false /*writeXsiType*/, primitiveContractForParamType: null);
                        ReflectionWriteEndElement(xmlWriter);
                    }
                }
            }

            return(memberCount);
        }