/// <summary>
        /// Gets the parent ID of an item.
        /// </summary>
        /// <param name="itemDefinition">The item definition.</param>
        /// <param name="context">The context.</param>
        /// <returns>Sitecore.Data.ID.</returns>
        public override ID GetParentID(ItemDefinition itemDefinition, CallContext context)
        {
            if (!_setupComplete)
            {
                return(base.GetParentID(itemDefinition, context));
            }

            var sectionTable = SectionTable.ToList();//prevent "Collection was modified"
            var section      = sectionTable.FirstOrDefault(x => x.SectionId == itemDefinition.ID);

            if (section != null)
            {
                return(section.TemplateId);
            }

            var fieldtable = FieldTable.ToList();//prevent "Collection was modified"
            var field      = fieldtable.FirstOrDefault(x => x.FieldId == itemDefinition.ID);

            if (field != null)
            {
                return(field.SectionId);
            }

            return(base.GetParentID(itemDefinition, context));
        }
        /// <summary>
        /// Gets the definition of an item.
        /// </summary>
        /// <param name="itemId">The item ID.</param>
        /// <param name="context">The context.</param>
        /// <returns>Sitecore.Data.ItemDefinition.</returns>
        public override ItemDefinition GetItemDefinition(ID itemId, CallContext context)
        {
            if (!_setupComplete)
            {
                return(base.GetItemDefinition(itemId, context));
            }

            var sectiontable = SectionTable.ToList();//prevent "Collection was modified"
            var section      = sectiontable.FirstOrDefault(x => x.SectionId == itemId);

            if (section != null)
            {
                return(new GlassItemDefinition(itemId, section.Name, SectionTemplateId, ID.Null));
            }

            var fieldtable = FieldTable.ToList();//prevent "Collection was modified"
            var field      = fieldtable.FirstOrDefault(x => x.FieldId == itemId);

            if (field != null)
            {
                return(new GlassItemDefinition(itemId, field.Name, FieldTemplateId, ID.Null));
            }

            return(base.GetItemDefinition(itemId, context));
        }
        /// <summary>
        /// Gets the fields of a specific item version.
        /// </summary>
        /// <param name="itemDefinition">The item.</param>
        /// <param name="versionUri">The version URI.</param>
        /// <param name="context">The context.</param>
        /// <returns>Sitecore.Data.FieldList.</returns>
        public override FieldList GetItemFields(ItemDefinition itemDefinition, VersionUri versionUri, CallContext context)
        {
            if (!_setupComplete)
            {
                return(base.GetItemFields(itemDefinition, versionUri, context));
            }

            var fields = new FieldList();

            var sectionTable = SectionTable.ToList();//prevent "Collection was modified"
            var sectionInfo  = sectionTable.FirstOrDefault(x => x.SectionId == itemDefinition.ID);

            if (sectionInfo != null)
            {
                GetStandardFields(fields, sectionInfo.SectionSortOrder >= 0 ? sectionInfo.SectionSortOrder : 100);

                return(fields);
            }

            var fieldtable = FieldTable.ToList();//prevent "Collection was modified"
            var fieldInfo  = fieldtable.FirstOrDefault(x => x.FieldId == itemDefinition.ID);

            if (fieldInfo != null)
            {
                GetStandardFields(fields, fieldInfo.FieldSortOrder >= 0 ? fieldInfo.FieldSortOrder : 100);
                GetFieldFields(fieldInfo, fields);
                return(fields);
            }

            return(base.GetItemFields(itemDefinition, versionUri, context));
        }
示例#4
0
        public AssemblyLoader()
        {
            _signatureResolver = new SignatureResolver(this);

            _assemblyTable = new AssemblyTable(this);

            Const             = new ConstantTable(this);
            Files             = new FileTable(this);
            ManifestResources = new ManifestResourceTable(this);

            Modules = new ModuleTable(this);

            ModuleRefs   = new ModuleRefTable(this);
            AssemblyRefs = new AssemblyRefTable(this);

            TypeRefs    = new TypeRefTable(this);
            MemberRefs  = new MemberRefTable(this);
            _typeSpec   = new TypeSpecTable(this);
            _methodSpec = new MethodSpecTable(this);

            Parameters        = new ParamTable(this);
            Fields            = new FieldTable(this);
            Properties        = new PropertyTable(this);
            Events            = new EventTable(this);
            GenericParameters = new GenericParamTable(this);

            Methods = new MethodTable(this);
            Types   = new TypeTable(this);
        }
示例#5
0
        private void MakeTree(TypeDefTable t1, TypeDefTable t2)
        {
            t1.Children = new ArrayList[]
            {
                new ArrayList(), new ArrayList(), new ArrayList()
            }
            ;
            ArrayList listField = this.Tables[(int)MetadataTables.Field];
            ArrayList listMethod = this.Tables[(int)MetadataTables.MethodDef];
            int       f1 = t1.FieldList, f2 = (t2 != null) ? t2.FieldList:
                                              listField.Count + 1;

            for (int i = f1; i < f2; i++)
            {
                FieldTable f = listField[i - 1] as FieldTable;
                t1.Children[(int)Children.DefField].Add(f);
                f.ParentTable = t1;
            }
            int m1 = t1.MethodList, m2 = (t2 != null) ? t2.MethodList:
                                         listMethod.Count + 1;

            for (int i = m1; i < m2; i++)
            {
                MethodDefTable m = listMethod[i - 1] as MethodDefTable;
                t1.Children[(int)Children.DefMethod].Add(m);
                m.ParentTable = t1;
                this.MakeTree(m);
            }
        }
 public FieldTable PopulateHeadersFromMessageProperties()
 {
     if (ContentHeaderProperties.Headers == null)
     {
         return(null);
     }
     else
     {
         //
         // We need to convert every property into a String representation
         // Note that type information is preserved in the property name
         //
         FieldTable table = new FieldTable();
         foreach (DictionaryEntry entry in  ContentHeaderProperties.Headers)
         {
             string propertyName = (string)entry.Key;
             if (propertyName == null)
             {
                 continue;
             }
             else
             {
                 table[propertyName] = entry.Value.ToString();
             }
         }
         return(table);
     }
 }
示例#7
0
        //**************************************************************************
        // Function:	EditEntryAsync
        //
        // Description:	Edit a field entry from the database
        //
        // Parameters:	entry	-	Entry to be edited
        //
        // Returns:		Response of the API
        //**************************************************************************
        public async Task <FieldTable> EditEntryAsync(FieldTable entry)
        {
            var url      = new Uri(baseUri, "/api/fieldEntry");
            var response = await SendRequestAsync <FieldTable> (url, HttpMethod.Put, headers, entry);

            return(response);
        }
示例#8
0
        /// <summary>
        /// Gets the fields of a specific item version.
        /// </summary>
        /// <param name="itemDefinition">The item.</param>
        /// <param name="versionUri">The version URI.</param>
        /// <param name="context">The context.</param>
        /// <returns>Sitecore.Data.FieldList.</returns>
        public override FieldList GetItemFields(ItemDefinition itemDefinition, VersionUri versionUri, CallContext context)
        {
            if (!_setupComplete)
            {
                return(base.GetItemFields(itemDefinition, versionUri, context));
            }

            var fields = new FieldList();

            var sectionInfo = SectionTable.FirstOrDefault(x => x.SectionId == itemDefinition.ID);

            if (sectionInfo != null)
            {
                GetStandardFields(fields, sectionInfo.SectionSortOrder >= 0 ? sectionInfo.SectionSortOrder : (SectionTable.IndexOf(sectionInfo) + 100));

                return(fields);
            }

            var fieldInfo = FieldTable.FirstOrDefault(x => x.FieldId == itemDefinition.ID);

            if (fieldInfo != null)
            {
                GetStandardFields(fields, fieldInfo.FieldSortOrder >= 0 ? fieldInfo.FieldSortOrder : (FieldTable.IndexOf(fieldInfo) + 100));
                GetFieldFields(fieldInfo, fields);
                return(fields);
            }

            return(base.GetItemFields(itemDefinition, versionUri, context));
        }
示例#9
0
 public QpidHeaders(FieldTable headers)
 {
     if (headers == null)
     {
         throw new ArgumentNullException("headers");
     }
     _headers = headers;
 }
示例#10
0
 //**************************************************************************
 // Function:	loadFieldInfo
 //
 // Description:	Calls the API and loads the returned data into a member variable
 //
 // Parameters:	None
 //
 // Returns:		None
 //**************************************************************************
 private async void loadFieldInfo()
 {
     this.currField = this.fieldBackend.getSpecificField(App.FieldID);
     if (currField == null)
     {
         Debug.WriteLine("Finding Current Field Failed");
         await Application.Current.MainPage.Navigation.PopAsync();
     }
 }
 //**************************************************************************
 // Function:	setPlaceholder
 //
 // Description:	Get the current field data to display as place holders
 //
 // Parameters:	None
 //
 // Returns:		None
 //**************************************************************************
 private async void setPlaceholder()
 {
     this.singleField = this.fieldBackend.getSpecificField(App.FieldID);
     if (singleField == null)
     {
         Debug.WriteLine("Finding Current Field Failed");
         await PopupNavigation.Instance.PopAsync(true);
     }
 }
示例#12
0
        private void getTablesFromTexts(out FieldTable table1, out FieldTable table2)
        {
            Tuple <ulong, ulong> validValues = IOManager.GetValidInput(firstValueTextBox.Text, secondValueTextBox.Text);
            Polynomial           polynomial1 = new Polynomial(validValues.Item1);
            Polynomial           polynomial2 = new Polynomial(validValues.Item2);

            table1 = new FieldTable(polynomial1);
            table2 = new FieldTable(polynomial2);
        }
示例#13
0
        /// <summary> Returns a field table containing patterns to match the test header exchange against. </summary>
        ///
        /// <returns> A field table containing test patterns. </returns>
        private FieldTable CreatePatternAsFieldTable()
        {
            FieldTable matchTable = new FieldTable();

            matchTable["match1"]  = "foo";
            matchTable["match2"]  = "";
            matchTable["x-match"] = "all";

            return(matchTable);
        }
        //**************************************************************************
        // Function:	SubmitButton_Clicked
        //
        // Description:	When the submit button is clicked this command will check update the
        //				table entry according to the values they specified
        //
        // Parameters:	sender	-	Object that sent the message
        //				e		-	List View item that was tapped
        //
        // Returns:		None
        //**************************************************************************
        public async void SubmitButton_Clicked(object sender, EventArgs args)
        {
            FieldTable updatedField = new FieldTable(ref singleField);
            bool       bPopOff      = true;

            if (false == this.areEntriesFilled())
            {
                await App.Current.MainPage.DisplayAlert("Update Field Alert", "No New Entries", "OK");

                bPopOff = false;
            }
            else
            {
                // Update based on which entries got filled out
                if (false == string.IsNullOrEmpty(fieldname.Text))
                {
                    // Verify Unique field name
                    if (true == this.fieldBackend.DoesFieldNameExist(fieldname.Text))
                    {
                        await App.Current.MainPage.DisplayAlert("Update Field Alert", "Field Name Already Exists", "OK");

                        bPopOff = false;
                    }
                    else
                    {
                        updatedField.FieldName = fieldname.Text;
                    }
                }
                if (-1 != pivotlength.SelectedIndex)
                {
                    updatedField.PivotLength = (int)pivotlength.ItemsSource[pivotlength.SelectedIndex];
                }
                if (-1 != soiltype.SelectedIndex)
                {
                    updatedField.SoilType = (string)soiltype.ItemsSource[soiltype.SelectedIndex];
                }
            }


            // If valid new field then edit existing
            if (true == bPopOff)
            {
                // If pivot length or soil type were changed need to redo equation
                if (-1 != pivotlength.SelectedIndex || -1 != soiltype.SelectedIndex)
                {
                    updatedField.WaterUsage = RainCat.WaterUsage(ref updatedField);
                }

                await this.fieldBackend.UpdateField(updatedField);

                await PopupNavigation.Instance.PopAsync(true);

                CallbackEvent?.Invoke(this, EventArgs.Empty);
            }
        }
示例#15
0
 /// <summary>
 /// 根据属性名字设定目标实例对应的值
 /// </summary>
 /// <param name="memberName"></param>
 /// <param name="value"></param>
 /// <param name="index"></param>
 public void TrySetValue(string memberName, object value, params object[] index)
 {
     if (FieldTable.TryGetValue(memberName, out FieldInfo fieldInfo))
     {
         fieldInfo.SetValue(_instance, value);
     }
     else if (PropertyTable.TryGetValue(memberName, out PropertyInfo propertyInfo))
     {
         propertyInfo.SetValue(_instance, value, index);
     }
 }
示例#16
0
        internal CatchScope(ActivationObject parent, Context argContext, JSParser parser)
            : base(parent, argContext, parser)
        {
            // get the name of the catch variable
            m_name = Context.Code;

            // add it to the catch-scope's name table
            JSVariableField field = new JSArgumentField(m_name, null);

            NameTable[m_name] = field;
            FieldTable.Add(field);
        }
        public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt)
        {
            ConnectionStartBody body = (ConnectionStartBody)evt.Method;
            AMQProtocolSession  ps   = evt.ProtocolSession;

            try
            {
                if (body.Mechanisms == null)
                {
                    throw new AMQException("mechanism not specified in ConnectionStart method frame");
                }
                string mechanisms        = Encoding.UTF8.GetString(body.Mechanisms);
                string selectedMechanism = ChooseMechanism(mechanisms);
                if (selectedMechanism == null)
                {
                    throw new AMQException("No supported security mechanism found, passed: " + mechanisms);
                }

                byte[] saslResponse = DoAuthentication(selectedMechanism, ps);

                if (body.Locales == null)
                {
                    throw new AMQException("Locales is not defined in Connection Start method");
                }
                string   allLocales = Encoding.ASCII.GetString(body.Locales);
                string[] locales    = allLocales.Split(' ');
                string   selectedLocale;
                if (locales != null && locales.Length > 0)
                {
                    selectedLocale = locales[0];
                }
                else
                {
                    throw new AMQException("No locales sent from server, passed: " + locales);
                }

                stateManager.ChangeState(AMQState.CONNECTION_NOT_TUNED);
                FieldTable clientProperties = new FieldTable();
                clientProperties["product"]  = "Apache.Qpid.NET";
                clientProperties["version"]  = "1.0";
                clientProperties["platform"] = GetFullSystemInfo();
                clientProperties["instance"] = ps.ClientID;
                AMQFrame frame = ConnectionStartOkBody.CreateAMQFrame(
                    evt.ChannelId, clientProperties, selectedMechanism,
                    saslResponse, selectedLocale);
                ps.WriteFrame(frame);
            }
            catch (Exception e)
            {
                throw new AMQException(_log, "Unable to decode data: " + e, e);
            }
        }
示例#18
0
        /// <summary>
        /// Gets the child I ds section.
        /// </summary>
        /// <param name="section">The section.</param>
        /// <param name="context">The context.</param>
        /// <param name="sqlProvider">The SQL provider.</param>
        /// <returns>
        /// IDList.
        /// </returns>
        private IDList GetChildIDsSection(SectionInfo section, CallContext context, DataProvider sqlProvider)
        {
            var cls      = TypeConfigurations.First(x => x.Value.TemplateId == section.TemplateId).Value;
            var fields   = cls.Properties.OfType <SitecoreFieldConfiguration>();
            var fieldIds = new IDList();

            foreach (var field in fields)
            {
                if (field.PropertyInfo.DeclaringType != cls.Type)
                {
                    continue;
                }

                if (field.CodeFirst && field.SectionName == section.Name && !ID.IsNullOrEmpty(field.FieldId))
                {
                    var record = FieldTable.FirstOrDefault(x => x.FieldId == field.FieldId);
                    //test if the fields exists in the database: if so, we're using codefirst now, so remove it.
                    var existing = sqlProvider.GetItemDefinition(field.FieldId, context);
                    if (existing != null)
                    {
                        using (new SecurityDisabler())
                            sqlProvider.DeleteItem(existing, context);
                    }

                    if (record == null)
                    {
                        string fieldName = field.FieldName.IsNullOrEmpty() ? field.PropertyInfo.Name : field.FieldName;

                        record = new FieldInfo(field.FieldId, section.SectionId, fieldName, field.FieldType, field.CustomFieldType,
                                               field.FieldSource, field.FieldTitle, field.IsShared, field.IsUnversioned,
                                               field.FieldSortOrder, field.ValidationRegularExpression,
                                               field.ValidationErrorText, field.IsRequired);

                        if (field.FieldValueConfigs != null && field.FieldValueConfigs.Any())
                        {
                            foreach (var ffv in field.FieldValueConfigs)
                            {
                                record.FieldFieldValues.Add(ffv.FieldId, ffv.FieldValue);
                            }
                        }
                    }

                    fieldIds.Add(record.FieldId);
                    FieldTable.Add(record);
                }
            }

            return(fieldIds);
        }
示例#19
0
 /// <summary>
 /// 根据属性名字获取目标实例对应的值
 /// </summary>
 /// <param name="memberName"></param>
 /// <param name="value"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 public bool TryGetValue(string memberName, out object value, params object[] index)
 {
     if (FieldTable.TryGetValue(memberName, out FieldInfo fieldInfo))
     {
         value = fieldInfo.GetValue(_instance);
         return(true);
     }
     else if (PropertyTable.TryGetValue(memberName, out PropertyInfo propertyInfo))
     {
         value = propertyInfo.GetValue(_instance, index);
         return(true);
     }
     value = null;
     return(false);
 }
示例#20
0
        //**************************************************************************
        // Function:	OnDelete_Selected
        //
        // Description:	Verify the deletion of the field, and then delete if yes
        //
        // Parameters:	sender	-	Object that sent the message
        //				e		-	List View item that was tapped
        //
        // Returns:		None
        //**************************************************************************
        public async void OnDelete_Selected(object sender, EventArgs e)
        {
            FieldTable fieldMenuItem = ((MenuItem)sender).CommandParameter as FieldTable;

            bool answer = await App.Current.MainPage.DisplayAlert("Delete Field?",
                                                                  "Are you sure you want to delete:  " + fieldMenuItem.FieldName + "? \nThis cannot be undone.",
                                                                  "Yes", "No");

            if (true == answer)
            {
                await this.fieldBackend.DeleteField(fieldMenuItem);

                Debug.WriteLine("Field Deleted");
                this.OnAppearing();
            }
        }
示例#21
0
        /// <summary>
        /// Returns a table's name
        /// </summary>
        /// <param name="pType">Record type</param>
        /// <returns></returns>
        public static String GetTableName(Type pType)
        {
            String _TableName = String.Empty;

            object[] members = pType.GetCustomAttributes(typeof(FieldTable), true);
            foreach (object obj in members)
            {
                if (obj is FieldTable)
                {
                    FieldTable ft = obj as FieldTable;
                    _TableName = "[" + ft.TableName + "]";
                    return(_TableName);
                }
            }
            throw new RecordTableNullException("Table's name is null");
        }
示例#22
0
        /// <summary>
        /// Gets the field table for any object.
        /// </summary>
        /// <param name="any">Any object to obtain a field table for.</param>
        /// <returns>A reference to a field table.</returns>
        /// <remarks>It will cache the field table in a hash for quick lookup at a later time.</remarks>
        public static FieldTable GetFieldTable(ref object any)
        {
            if (any == null)
            {
                return(null);
            }
            string     typefullname = any.GetType().FullName;
            FieldTable ft           = _fieldtablehash[typefullname] as FieldTable;

            if (ft == null)
            {
                ft = new FieldTable(any);
                _fieldtablehash[typefullname] = ft;
            }

            return(ft);
        }
示例#23
0
        void EncodeFieldTable(FieldTable table)
        {
            int index = 0;

            foreach (FieldRow row in table.Rows)
            {
                this.asm.ALIGN(Assembly.OBJECT_ALIGNMENT);
                this.asm.LABEL(moduleName + " FieldRow#" + index);
                this.asm.AddObjectFields(typeof(SharpOS.AOT.Metadata.FieldRow).ToString());

                this.asm.DATA((uint)row.Flags);
                this.asm.DATA(row.Name);
                this.asm.DATA(row.Signature);
                ++index;
            }

            this.MetadataArray("Field", table);
        }
示例#24
0
    public bool WriteAsm(StreamWriter sw, TypeDefTable t)
    {
        bool ok = true;

        sw.WriteLine("; class {0}", this.pedata.idxm.GetName(t));
        bool first = true;

        foreach (object obj in t.Children[(int)Children.DefField])
        {
            FieldTable f = obj as FieldTable;
            if ((f.Flags & (int)FieldAttributes.Static) == 0 ||
                (f.Flags & (int)FieldAttributes.Literal) != 0)
            {
                continue;
            }

            if (first)
            {
                sw.WriteLine();
                first = false;
            }
            sw.WriteLine("{0} dw 0", MangleField(f));
        }
        foreach (object obj in t.Children[(int)Children.DefMethod])
        {
            MethodDefTable m  = obj as MethodDefTable;
            MethodData     md = m.Tag as MethodData;
            if (md.HasThis)
            {
                continue;                         // static only
            }
            sw.WriteLine();
            if (!this.WriteAsm(sw, md))
            {
                ok = false;
            }
        }
        return(ok);
    }
示例#25
0
        /// <summary>
        /// Gets the definition of an item.
        /// </summary>
        /// <param name="itemId">The item ID.</param>
        /// <param name="context">The context.</param>
        /// <returns>Sitecore.Data.ItemDefinition.</returns>
        public override ItemDefinition GetItemDefinition(ID itemId, CallContext context)
        {
            if (!_setupComplete)
            {
                return(base.GetItemDefinition(itemId, context));
            }

            var section = SectionTable.FirstOrDefault(x => x.SectionId == itemId);

            if (section != null)
            {
                return(new ItemDefinition(itemId, section.Name, SectionTemplateId, ID.Null));
            }

            var field = FieldTable.FirstOrDefault(x => x.FieldId == itemId);

            if (field != null)
            {
                return(new ItemDefinition(itemId, field.Name, FieldTemplateId, ID.Null));
            }

            return(base.GetItemDefinition(itemId, context));
        }
示例#26
0
        /// <summary>
        /// Gets the parent ID of an item.
        /// </summary>
        /// <param name="itemDefinition">The item definition.</param>
        /// <param name="context">The context.</param>
        /// <returns>Sitecore.Data.ID.</returns>
        public override ID GetParentID(ItemDefinition itemDefinition, CallContext context)
        {
            if (!_setupComplete)
            {
                return(base.GetParentID(itemDefinition, context));
            }

            var section = SectionTable.FirstOrDefault(x => x.SectionId == itemDefinition.ID);

            if (section != null)
            {
                return(section.TemplateId);
            }

            var field = FieldTable.FirstOrDefault(x => x.FieldId == itemDefinition.ID);

            if (field != null)
            {
                return(field.SectionId);
            }

            return(base.GetParentID(itemDefinition, context));
        }
示例#27
0
        /// <summary>
        /// The backing field of a WinRT enumeration type is not public although the backing fields
        /// of managed enumerations are. To allow managed languages to directly access this field,
        /// it is made public by the metadata adapter.
        /// </summary>
        private uint CalculateFieldDefTreatmentAndRowId(FieldDefinitionHandle handle)
        {
            var flags = FieldTable.GetFlags(handle);
            FieldDefTreatment treatment = FieldDefTreatment.None;

            if ((flags & FieldAttributes.RTSpecialName) != 0 && StringStream.EqualsRaw(FieldTable.GetName(handle), "value__"))
            {
                TypeDefinitionHandle typeDef = GetDeclaringType(handle);

                EntityHandle baseTypeHandle = TypeDefTable.GetExtends(typeDef);
                if (baseTypeHandle.Kind == HandleKind.TypeReference)
                {
                    var typeRef = (TypeReferenceHandle)baseTypeHandle;

                    if (StringStream.EqualsRaw(TypeRefTable.GetName(typeRef), "Enum") &&
                        StringStream.EqualsRaw(TypeRefTable.GetNamespace(typeRef), "System"))
                    {
                        treatment = FieldDefTreatment.EnumValue;
                    }
                }
            }

            return(TreatmentAndRowId((byte)treatment, handle.RowId));
        }
示例#28
0
        public void TestQueueBrowsingLVQ()
        {
            // Create a topic with one producer and two consumers.
            SetUpEndPoint(0, true, false, TEST_ROUTING_KEY2 + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT, true, true, TEST_ROUTING_KEY2 + testId, false, false);
            FieldTable args = new FieldTable();

            args.SetBoolean("qpid.last_value_queue", true);
            args.SetString("qpid.last_value_queue_key", "key");
            testChannel[0].DeclareQueue(TEST_ROUTING_KEY2 + testId, true, false, false, args);
            testChannel[0].Bind(TEST_ROUTING_KEY2 + testId, ExchangeNameDefaults.DIRECT, TEST_ROUTING_KEY2 + testId);
            Thread.Sleep(500);


            for (int i = 0; i < 12; i++)
            {
                ITextMessage msg = testChannel[0].CreateTextMessage("msg");
                msg.Headers.SetInt("key", i % 6);
                testProducer[0].Send(msg);
            }

            Thread.Sleep(2000);

            SetUpEndPoint(1, false, true, TEST_ROUTING_KEY2 + testId, AcknowledgeMode.NoAcknowledge, false, ExchangeNameDefaults.DIRECT, true, true, TEST_ROUTING_KEY2 + testId, false, true);
            SetUpEndPoint(2, false, true, TEST_ROUTING_KEY2 + testId, AcknowledgeMode.NoAcknowledge, false, ExchangeNameDefaults.DIRECT, true, true, TEST_ROUTING_KEY2 + testId, false, true);

            Thread.Sleep(500);


            ConsumeNMessagesOnly(6, "msg", testConsumer[1]);
            ConsumeNMessagesOnly(6, "msg", testConsumer[2]);

            // Clean up any open consumers at the end of the test.
            CloseEndPoint(2);
            CloseEndPoint(1);
            CloseEndPoint(0);
        }
示例#29
0
        /// <summary>
        /// Gets the truth indicator of whether we can process the xml attribute or not.
        /// </summary>
        /// <param name="attributeContainer">The class or object containing the attributes themselves.</param>
        /// <param name="attributeEntry">The dictionary entry of the attribute (name value pair).</param>
        /// <returns>True if we can process and false otherwise.</returns>
        public static bool CanProcessAttribute(object attributeContainer, ref System.Collections.DictionaryEntry attributeEntry)
        {
            if (attributeContainer == null)
            {
                return(false);                                        // of course we can't process
            }
            string key = attributeEntry.Key as string;

            // translate the value from boolean indicators to Y | N
            if (attributeEntry.Value != null && attributeEntry.Value.GetType() == typeof(System.Boolean))
            {
                bool boolval = (bool)attributeEntry.Value;
                attributeEntry.Value = (boolval ? "Y" : "N");
            }

            if (key != null)             // reject the framewok attributes
            {
                if (key.IndexOf("IsNull") >= 0)
                {
                    return(false);
                }
                if (key == "BusinessExceptions")
                {
                    return(false);
                }
                if (key == "IsModified")
                {
                    return(false);
                }
                if (key == "Deleted")
                {
                    return(false);
                }
                if (key == "Id")
                {
                    return(false);
                }
                if (key == "Persisted")
                {
                    return(false);
                }
                if (key == "LoanApplicationId")
                {
                    return(false);
                }
            }

            // reject null values or anything that isn't a value type except for a string
            if (attributeEntry.Value == null || !(attributeEntry.Value.GetType().IsValueType || attributeEntry.Value is string))
            {
                return(false);
            }


            FieldTable ft = GetFieldTable(ref attributeContainer);

            if (ft != null)
            {
                bool   unassignedindicator        = false;
                object tempval                    = null;
                System.Reflection.FieldInfo field = null;

                field = ft[string.Format("_{0}_isnull", key.ToLower())];
                if (field != null)
                {
                    tempval = field.GetValue(attributeContainer);
                    if (tempval != null)
                    {
                        unassignedindicator = (bool)tempval;
                        if (unassignedindicator)
                        {
                            return(false);
                        }
                    }
                }

                field = ft[string.Format("_{0}_assigned", key.ToLower())];
                if (field != null)
                {
                    tempval = field.GetValue(attributeContainer);
                    if (tempval != null)
                    {
                        unassignedindicator = !((bool)tempval);
                        if (unassignedindicator)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
 public void NewGame()
 {
     _table    = new FieldTable();
     _gameTime = 0;
 }
示例#31
0
        public void Read(ReaderContext ctxt)
        {
            var reader = ctxt.GetTablesReader();

            var actualReserved0 = reader.ReadUInt32();
            if (actualReserved0 != reserved0)
                throw new PEException("invalid MetadataTable header");
            var actualMajorVersion = reader.ReadByte();
            if (actualMajorVersion != majorVersion)
                throw new PEException("invalid MetadataTable header");
            var actualMinorVersion = reader.ReadByte();
            if (actualMinorVersion != minorVersion)
                throw new PEException("invalid MetadataTable header");
            var heapSizes = reader.ReadByte();
            IsStringStreamBig = (heapSizes & 0x01) != 0;
            IsGuidStreamBig = (heapSizes & 0x02) != 0;
            IsBlobStreamBig = (heapSizes & 0x04) != 0;
            Reserved1 = reader.ReadByte();

            var valid = new IntSet64(reader.ReadUInt64());
            var sorted = new IntSet64(reader.ReadUInt64());

            for (var i = 0; i < 64; i++)
            {
                var numRows = 0;
                if (valid[i])
                    numRows = (int)reader.ReadUInt32();

                switch ((TableTag)i)
                {
                case TableTag.Module:
                    ModuleTable = new ModuleTable(numRows);
                    break;
                case TableTag.Assembly:
                    AssemblyTable = new AssemblyTable(numRows);
                    break;
                case TableTag.AssemblyOS:
                    AssemblyOSTable = new AssemblyOSTable(numRows);
                    break;
                case TableTag.AssemblyProcessor:
                    AssemblyProcessorTable = new AssemblyProcessorTable(numRows);
                    break;
                case TableTag.AssemblyRef:
                    AssemblyRefTable = new AssemblyRefTable(numRows);
                    break;
                case TableTag.AssemblyRefOS:
                    AssemblyRefOSTable = new AssemblyRefOSTable(numRows);
                    break;
                case TableTag.AssemblyRefProcessor:
                    AssemblyRefProcessorTable = new AssemblyRefProcessorTable(numRows);
                    break;
                case TableTag.ClassLayout:
                    ClassLayoutTable = new ClassLayoutTable(numRows);
                    break;
                case TableTag.Constant:
                    ConstantTable = new ConstantTable(numRows);
                    break;
                case TableTag.CustomAttribute:
                    CustomAttributeTable = new CustomAttributeTable(numRows);
                    break;
                case TableTag.DeclSecurity:
                    DeclSecurityTable = new DeclSecurityTable(numRows);
                    break;
                case TableTag.EventMap:
                    EventMapTable = new EventMapTable(numRows);
                    break;
                case TableTag.Event:
                    EventTable = new EventTable(numRows);
                    break;
                case TableTag.ExportedType:
                    ExportedTypeTable = new ExportedTypeTable(numRows);
                    break;
                case TableTag.Field:
                    FieldTable = new FieldTable(numRows);
                    break;
                case TableTag.FieldLayout:
                    FieldLayoutTable = new FieldLayoutTable(numRows);
                    break;
                case TableTag.FieldMarshal:
                    FieldMarshalTable = new FieldMarshalTable(numRows);
                    break;
                case TableTag.FieldRVA:
                    FieldRVATable = new FieldRVATable(numRows);
                    break;
                case TableTag.File:
                    FileTable = new FileTable(numRows);
                    break;
                case TableTag.GenericParam:
                    GenericParamTable = new GenericParamTable(numRows);
                    break;
                case TableTag.GenericParamConstraint:
                    GenericParamConstraintTable = new GenericParamConstraintTable(numRows);
                    break;
                case TableTag.ImplMap:
                    ImplMapTable = new ImplMapTable(numRows);
                    break;
                case TableTag.InterfaceImpl:
                    InterfaceImplTable = new InterfaceImplTable(numRows);
                    break;
                case TableTag.ManifestResource:
                    ManifestResourceTable = new ManifestResourceTable(numRows);
                    break;
                case TableTag.MemberRef:
                    MemberRefTable = new MemberRefTable(numRows);
                    break;
                case TableTag.MethodDef:
                    MethodDefTable = new MethodDefTable(numRows);
                    break;
                case TableTag.MethodImpl:
                    MethodImplTable = new MethodImplTable(numRows);
                    break;
                case TableTag.MethodSemantics:
                    MethodSemanticsTable = new MethodSemanticsTable(numRows);
                    break;
                case TableTag.MethodSpec:
                    MethodSpecTable = new MethodSpecTable(numRows);
                    break;
                case TableTag.ModuleRef:
                    ModuleRefTable = new ModuleRefTable(numRows);
                    break;
                case TableTag.NestedClass:
                    NestedClassTable = new NestedClassTable(numRows);
                    break;
                case TableTag.Param:
                    ParamTable = new ParamTable(numRows);
                    break;
                case TableTag.Property:
                    PropertyTable = new PropertyTable(numRows);
                    break;
                case TableTag.PropertyMap:
                    PropertyMapTable = new PropertyMapTable(numRows);
                    break;
                case TableTag.StandAloneSig:
                    StandAloneSigTable = new StandAloneSigTable(numRows);
                    break;
                case TableTag.TypeDef:
                    TypeDefTable = new TypeDefTable(numRows);
                    break;
                case TableTag.TypeRef:
                    TypeRefTable = new TypeRefTable(numRows);
                    break;
                case TableTag.TypeSpec:
                    TypeSpecTable = new TypeSpecTable(numRows);
                    break;
                default:
                    // Ignore
                    break;
                }
            }

            DetermineIndexCodingSizes();

            for (var i = 0; i < 64; i++)
            {
                if (valid[i])
                {
                    switch ((TableTag)i)
                    {
                    case TableTag.Module:
                        ModuleTable.Read(ctxt, reader);
                        break;
                    case TableTag.Assembly:
                        AssemblyTable.Read(ctxt, reader);
                        break;
                    case TableTag.AssemblyOS:
                        AssemblyOSTable.Read(ctxt, reader);
                        break;
                    case TableTag.AssemblyProcessor:
                        AssemblyProcessorTable.Read(ctxt, reader);
                        break;
                    case TableTag.AssemblyRef:
                        AssemblyRefTable.Read(ctxt, reader);
                        break;
                    case TableTag.AssemblyRefOS:
                        AssemblyRefOSTable.Read(ctxt, reader);
                        break;
                    case TableTag.AssemblyRefProcessor:
                        AssemblyRefProcessorTable.Read(ctxt, reader);
                        break;
                    case TableTag.ClassLayout:
                        ClassLayoutTable.Read(ctxt, reader);
                        break;
                    case TableTag.Constant:
                        ConstantTable.Read(ctxt, reader);
                        break;
                    case TableTag.CustomAttribute:
                        CustomAttributeTable.Read(ctxt, reader);
                        break;
                    case TableTag.DeclSecurity:
                        DeclSecurityTable.Read(ctxt, reader);
                        break;
                    case TableTag.EventMap:
                        EventMapTable.Read(ctxt, reader);
                        break;
                    case TableTag.Event:
                        EventTable.Read(ctxt, reader);
                        break;
                    case TableTag.ExportedType:
                        ExportedTypeTable.Read(ctxt, reader);
                        break;
                    case TableTag.Field:
                        FieldTable.Read(ctxt, reader);
                        break;
                    case TableTag.FieldLayout:
                        FieldLayoutTable.Read(ctxt, reader);
                        break;
                    case TableTag.FieldMarshal:
                        FieldMarshalTable.Read(ctxt, reader);
                        break;
                    case TableTag.FieldRVA:
                        FieldRVATable.Read(ctxt, reader);
                        break;
                    case TableTag.File:
                        FileTable.Read(ctxt, reader);
                        break;
                    case TableTag.GenericParam:
                        GenericParamTable.Read(ctxt, reader);
                        break;
                    case TableTag.GenericParamConstraint:
                        GenericParamConstraintTable.Read(ctxt, reader);
                        break;
                    case TableTag.ImplMap:
                        ImplMapTable.Read(ctxt, reader);
                        break;
                    case TableTag.InterfaceImpl:
                        InterfaceImplTable.Read(ctxt, reader);
                        break;
                    case TableTag.ManifestResource:
                        ManifestResourceTable.Read(ctxt, reader);
                        break;
                    case TableTag.MemberRef:
                        MemberRefTable.Read(ctxt, reader);
                        break;
                    case TableTag.MethodDef:
                        MethodDefTable.Read(ctxt, reader);
                        break;
                    case TableTag.MethodImpl:
                        MethodImplTable.Read(ctxt, reader);
                        break;
                    case TableTag.MethodSemantics:
                        MethodSemanticsTable.Read(ctxt, reader);
                        break;
                    case TableTag.MethodSpec:
                        MethodSpecTable.Read(ctxt, reader);
                        break;
                    case TableTag.ModuleRef:
                        ModuleRefTable.Read(ctxt, reader);
                        break;
                    case TableTag.NestedClass:
                        NestedClassTable.Read(ctxt, reader);
                        break;
                    case TableTag.Param:
                        ParamTable.Read(ctxt, reader);
                        break;
                    case TableTag.Property:
                        PropertyTable.Read(ctxt, reader);
                        break;
                    case TableTag.PropertyMap:
                        PropertyMapTable.Read(ctxt, reader);
                        break;
                    case TableTag.StandAloneSig:
                        StandAloneSigTable.Read(ctxt, reader);
                        break;
                    case TableTag.TypeDef:
                        TypeDefTable.Read(ctxt, reader);
                        break;
                    case TableTag.TypeRef:
                        TypeRefTable.Read(ctxt, reader);
                        break;
                    case TableTag.TypeSpec:
                        TypeSpecTable.Read(ctxt, reader);
                        break;
                    default:
                        throw new PEException("unexpected table tag in MetadataTable body");
                    }
                }
            }

            ModuleTable.ResolveIndexes(ctxt);
            TypeRefTable.ResolveIndexes(ctxt);
            TypeDefTable.ResolveIndexes(ctxt);
            FieldTable.ResolveIndexes(ctxt);
            MethodDefTable.ResolveIndexes(ctxt);
            ParamTable.ResolveIndexes(ctxt);
            InterfaceImplTable.ResolveIndexes(ctxt);
            MemberRefTable.ResolveIndexes(ctxt);
            ConstantTable.ResolveIndexes(ctxt);
            CustomAttributeTable.ResolveIndexes(ctxt);
            FieldMarshalTable.ResolveIndexes(ctxt);
            DeclSecurityTable.ResolveIndexes(ctxt);
            ClassLayoutTable.ResolveIndexes(ctxt);
            FieldLayoutTable.ResolveIndexes(ctxt);
            StandAloneSigTable.ResolveIndexes(ctxt);
            EventMapTable.ResolveIndexes(ctxt);
            EventTable.ResolveIndexes(ctxt);
            PropertyMapTable.ResolveIndexes(ctxt);
            PropertyTable.ResolveIndexes(ctxt);
            MethodSemanticsTable.ResolveIndexes(ctxt);
            MethodImplTable.ResolveIndexes(ctxt);
            ModuleRefTable.ResolveIndexes(ctxt);
            TypeSpecTable.ResolveIndexes(ctxt);
            ImplMapTable.ResolveIndexes(ctxt);
            FieldRVATable.ResolveIndexes(ctxt);
            AssemblyTable.ResolveIndexes(ctxt);
            AssemblyProcessorTable.ResolveIndexes(ctxt);
            AssemblyOSTable.ResolveIndexes(ctxt);
            AssemblyRefTable.ResolveIndexes(ctxt);
            AssemblyRefProcessorTable.ResolveIndexes(ctxt);
            AssemblyRefOSTable.ResolveIndexes(ctxt);
            FileTable.ResolveIndexes(ctxt);
            ExportedTypeTable.ResolveIndexes(ctxt);
            ManifestResourceTable.ResolveIndexes(ctxt);
            NestedClassTable.ResolveIndexes(ctxt);
            GenericParamTable.ResolveIndexes(ctxt);
            MethodSpecTable.ResolveIndexes(ctxt);
            GenericParamConstraintTable.ResolveIndexes(ctxt);
        }
 public virtual void VisitFieldTable(FieldTable table)
 {
 }