public static string  stringFromValue(TypeValue the_enum)
    {
        switch (the_enum)
        {
        case TypeValue.Value_First:
            return("First");

        case TypeValue.Value_Second:
            return("Second");

        case TypeValue.Value_Third:
            return("Third");

        case TypeValue.Value_ThirdMale:
            return("ThirdMale");

        case TypeValue.Value_ThirdFemale:
            return("ThirdFemale");

        case TypeValue.Value_ThirdObject:
            return("ThirdObject");

        default:
            Debug.Assert(false);
            return(null);
        }
    }
示例#2
0
        protected override void handle_result(TypeValue new_value)
        {
            SportsOlympicsBasicAttributeTypeJSON result = new SportsOlympicsBasicAttributeTypeJSON();

            result.setValue(new_value);
            handle_result(result);
        }
        protected override void handle_result(TypeValue new_value)
        {
            AgeCalculatorPerspectiveJSON result = new AgeCalculatorPerspectiveJSON();

            result.setValue(new_value);
            handle_result(result);
        }
示例#4
0
        protected override void handle_result(TypeValue new_value)
        {
            SportsStandingsQueryTypeJSON result = new SportsStandingsQueryTypeJSON();

            result.setValue(new_value);
            handle_result(result);
        }
        protected override void handle_result(TypeValue new_value)
        {
            HomeAutomationTurboModeJSON result = new HomeAutomationTurboModeJSON();

            result.setValue(new_value);
            handle_result(result);
        }
示例#6
0
        private byte[] handlePairStepTwo(List <TypeValue> requestValue)
        {
            //var newSalt = SRP.s();
            var a  = requestValue.FirstOrDefault(x => x.Type == kTLVType_PublicKey.Type); // "A is a public key that exists only for a single login session."
            var M1 = requestValue.FirstOrDefault(x => x.Type == kTLVType_Proof.Type);     // "M1 is the proof that you actually know your own password."

            var clientsA = SRP.A(a.Value);

            var session = SRP.K_Service(a.Value, Encoding.UTF8.GetBytes("Pair-Setup"), Encoding.UTF8.GetBytes("11111111"), _SRP_b);

            var _M2 = SRP.M2(clientsA, M1.Value, session);

            var sequence = new TypeValue()
            {
                Type = kTLVType_State.Type, Value = new byte[] { 0x04 }
            };
            var passowrdProof_M2 = new TypeValue()
            {
                Type = kTLVType_Proof.Type, Value = _M2
            };

            var result = HomeKit.Protocol.TypeLengthValue.TypeLengthValue.Encode(sequence, passowrdProof_M2);

            return(result);
        }
示例#7
0
        protected override void handle_result(TypeValue new_value)
        {
            SportsOlympicsEventSchedulesAndResultsErrorJSON result = new SportsOlympicsEventSchedulesAndResultsErrorJSON();

            result.setValue(new_value);
            handle_result(result);
        }
    private void  fromJSONValue(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONStringValue json_string = json_value.string_value();

        if (json_string == null)
        {
            throw new Exception("The value for field Value of HomeAutomationTurboModeJSON is not a string.");
        }
        TypeValue the_open_enum = new TypeValue();

        if (String.Compare(json_string.getData(), 0, "Turn", 0, 4, false) == 0)
        {
            switch (json_string.getData()[4])
            {
            case 'O':
                switch (json_string.getData()[5])
                {
                case 'f':
                    if ((String.Compare(json_string.getData(), 6, "f", 0, 1, false) == 0) && (json_string.getData().Length == 7))
                    {
                        the_open_enum.in_known_list = true;
                        the_open_enum.list_value    = TypeValueKnownValues.Value_TurnOff;
                        goto open_enum_is_done;
                    }
                    break;

                case 'n':
                    if (json_string.getData().Length == 6)
                    {
                        the_open_enum.in_known_list = true;
                        the_open_enum.list_value    = TypeValueKnownValues.Value_TurnOn;
                        goto open_enum_is_done;
                    }
                    break;

                default:
                    break;
                }
                break;

            case 'Q':
                if ((String.Compare(json_string.getData(), 5, "uiet", 0, 4, false) == 0) && (json_string.getData().Length == 9))
                {
                    the_open_enum.in_known_list = true;
                    the_open_enum.list_value    = TypeValueKnownValues.Value_TurnQuiet;
                    goto open_enum_is_done;
                }
                break;

            default:
                break;
            }
        }
        the_open_enum.in_known_list = false;
        the_open_enum.string_value  = json_string.getData();
        open_enum_is_done :;
        setValue(the_open_enum);
    }
示例#9
0
        protected override IValue VisitGenericName(GenericNameSyntax node)
        {
            //var info = ModelExtensions.GetSymbolInfo(context.RoslynModel, node);
            //var info2 = ModelExtensions.AnalyzeDataFlow(context.RoslynModel, node);
            //var info3 = context.RoslynModel.GetDeclaredSymbol(node);
            // var mg = ModelExtensions.GetMemberGroup(context.RoslynModel, node);


            var identifier   = InternalVisitTextIdentifier(node.Identifier.ValueText.Trim());
            var genericTypes = node.TypeArgumentList.Arguments.Select(Visit).ToArray();
            var gt1          = genericTypes.OfType <TypeValue>().ToArray();

            // Debug.Assert(genericTypes.Length == gt1.Length);
            if (identifier is UnknownIdentifierValue)
            {
                var xx = identifier as UnknownIdentifierValue;
                // Debug.Assert(xx.OptionalGenericTypes.Length == 0);
                {
                    var tu = context.MatchTypes(xx.Identifier, genericTypes.Length);
                    if (tu.Length > 1)
                    {
                        throw new Exception("Nie wiem co wybrać");
                    }
                    if (tu.Length == 1)
                    {
                        var dotn = tu[0];
                        if (dotn.IsGenericType)
                        {
                            dotn = dotn.MakeGenericType(gt1.Select(i => i.DotnetType).ToArray());
                        }
                        var g = new TypeValue(dotn);
                        return(Simplify(g));
                    }
                }
                var result = new UnknownIdentifierValue(xx.Identifier, genericTypes);
                return(Simplify(result));
            }
            if (gt1.Length <= 0)
            {
                return(base.VisitGenericName(node));
            }
            if (!(identifier is TypeValue))
            {
                throw new NotSupportedException();
            }
            var a = node.Identifier.ValueText.Trim();
            var b = context.MatchTypes(a, gt1.Length);

            if (b.Length != 1)
            {
                throw new NotSupportedException();
            }
            var t = b.First();

            Debug.Assert(t.IsGenericType);
            var tt = t.MakeGenericType(gt1.Select(i => i.DotnetType).ToArray());

            return(new TypeValue(tt));
        }
示例#10
0
        /// <summary>
        /// 返回分组的形式,规格选择
        /// </summary>
        /// <param name="skus"></param>
        /// <param name="styles"></param>
        /// <returns></returns>
        public List <TypeItem> GetStylesByGroup(List <SKUItem> skus, out List <StyleItem> styles)
        {
            //按规格种类列表
            List <TypeItem> items = new List <TypeItem>();

            styles = new List <StyleItem>();
            TypeItem item;
            Dictionary <int, List <TypeValue> > all = new Dictionary <int, List <TypeValue> >();

            foreach (SKUItem skuItem in skus)
            {
                string sku          = skuItem.SKU;
                int    innerStyleId = skuItem.StyleId;
                if (string.IsNullOrEmpty(sku))
                {
                    continue;
                }
                string[] arry = sku.Split('|');
                foreach (string s in arry)
                {
                    string[] a       = s.Split(':');
                    int      typeId  = int.Parse(a[0]);
                    int      valueId = int.Parse(a[1]);
                    if (!all.ContainsKey(typeId))
                    {
                        all.Add(typeId, new List <TypeValue>());
                    }

                    bool exists = false;
                    foreach (TypeValue a1 in all[typeId])
                    {
                        if (a1.Code == typeId + ":" + valueId)
                        {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        TypeValue v = new TypeValue(typeId, valueId, valueCache[valueId].Name);
                        all[typeId].Insert(0, v);
                    }
                }
                int stock = skuItem.Num;
                styles.Insert(0, new StyleItem()
                {
                    StyleId = innerStyleId, Code = sku, Num = stock
                });
            }
            foreach (KeyValuePair <int, List <TypeValue> > entry in all)
            {
                item        = new TypeItem();
                item.Name   = nameCache[entry.Key].Name;
                item.Id     = entry.Key;
                item.Values = entry.Value;
                items.Add(item);
            }
            return(items);
        }
示例#11
0
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            crmWorkflowContext.Trace("Started: Defra.CustMaster.Identity.WfActivities.ContactDetailType");

            RequestTypeValue.Set(executionContext, TypeValue.Get(executionContext).Value);

            crmWorkflowContext.Trace("Finished: Defra.CustMaster.Identity.WfActivities.ContactDetailType");
        }
示例#12
0
        protected override IValue VisitNullableType(NullableTypeSyntax node)
        {
            var ti = ModelExtensions.GetTypeInfo(state.Context.RoslynModel, node);
            var tt = state.Context.Roslyn_ResolveType(ti.Type);
            var r  = new TypeValue(tt);

            return(r);
        }
示例#13
0
        /// <inheritdoc />
        protected override void initializeObject(ObjectValue createdObject, TypeValue type)
        {
            var info = getObjectInfoStorage(createdObject);

            //TODO set info
            ReportMemoryEntryCreation();
            assign(info, new MemoryEntry(type));
        }
示例#14
0
 public HolderValue(TypeValue init_data)
 {
     have_data = true;
     data      = init_data;
     if (have_data)
     {
     }
 }
示例#15
0
        internal static IEnumerable <FunctionValue> ResolveMethods(TypeValue type, SnapshotBase snapshot)
        {
            var resolver = new TypeMethodResolver(snapshot);

            type.Accept(resolver);

            return(resolver._methods);
        }
示例#16
0
 public HolderValue(HolderValue other)
 {
     have_data = other.haveData();
     data      = other.referenced();
     if (have_data)
     {
     }
 }
示例#17
0
文件: Cron.cs 项目: bagundes/klib
        private void Load(TypeValue typeValue, int start, int end, int step)
        {
            var max  = 0;
            var min  = 0;
            var zero = 0;

            switch (typeValue)
            {
            case TypeValue.Minute: min = 0; max = 59; zero = 1; break;

            case TypeValue.Hour: min = 0; max = 23; zero = 1;  break;

            case TypeValue.Day: min = 1; max = 31; break;

            case TypeValue.Month: min = 1; max = 12; break;

            case TypeValue.Week: min = 0; max = 6; zero = 1;  break;

            default:
                throw new KLIBException(2, "Type Value invalid in Cron Load.");
            }

            // If values is zero
            end   = end == 0 ? max : end;
            start = start == 0 ? min : start;

            // Validation the conditions
            if (start < min || start > max || end < min || end > max || start > end)
            {
                throw new KLIBException(2, $"Value of {typeValue.ToString()} is wrong in the Cron");
            }

            int size = (end - start + zero) / step;
            var foo  = new int[size];
            int c    = 0;

            for (int i = start; i < end + zero; i += step)
            {
                foo[c++] = i;
            }


            switch (typeValue)
            {
            case TypeValue.Minute: minutes = foo; break;

            case TypeValue.Hour: hours = foo;  break;

            case TypeValue.Day: days = foo; break;

            case TypeValue.Month: months = foo; break;

            case TypeValue.Week: weeks = foo;  break;

            default:
                throw new KLIBException(2, "Type Value invalid in Cron Load.");
            }
        }
    public static string  stringFromValue(TypeValue the_enum)
    {
        switch (the_enum)
        {
        case TypeValue.Value_Status:
            return("Status");

        case TypeValue.Value_DepartureInformation:
            return("DepartureInformation");

        case TypeValue.Value_DepartureTime:
            return("DepartureTime");

        case TypeValue.Value_HasDeparted:
            return("HasDeparted");

        case TypeValue.Value_DepartureLocation:
            return("DepartureLocation");

        case TypeValue.Value_DepartureAirport:
            return("DepartureAirport");

        case TypeValue.Value_DepartureTerminal:
            return("DepartureTerminal");

        case TypeValue.Value_DepartureGate:
            return("DepartureGate");

        case TypeValue.Value_ArrivalInformation:
            return("ArrivalInformation");

        case TypeValue.Value_ArrivalTime:
            return("ArrivalTime");

        case TypeValue.Value_HasArrived:
            return("HasArrived");

        case TypeValue.Value_ArrivalLocation:
            return("ArrivalLocation");

        case TypeValue.Value_ArrivalAirport:
            return("ArrivalAirport");

        case TypeValue.Value_ArrivalTerminal:
            return("ArrivalTerminal");

        case TypeValue.Value_ArrivalGate:
            return("ArrivalGate");

        case TypeValue.Value_FlightDuration:
            return("FlightDuration");

        default:
            Debug.Assert(false);
            return(null);
        }
    }
示例#19
0
    private void  fromJSONValue(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONStringValue json_string = json_value.string_value();

        if (json_string == null)
        {
            throw new Exception("The value for field Value of CabinClassJSON is not a string.");
        }
        TypeValue the_open_enum = new TypeValue();

        switch (json_string.getData()[0])
        {
        case 'B':
            if ((String.Compare(json_string.getData(), 1, "usiness", 0, 7, false) == 0) && (json_string.getData().Length == 8))
            {
                the_open_enum.in_known_list = true;
                the_open_enum.list_value    = TypeValueKnownValues.Value_Business;
                goto open_enum_is_done;
            }
            break;

        case 'E':
            if ((String.Compare(json_string.getData(), 1, "conomy", 0, 6, false) == 0) && (json_string.getData().Length == 7))
            {
                the_open_enum.in_known_list = true;
                the_open_enum.list_value    = TypeValueKnownValues.Value_Economy;
                goto open_enum_is_done;
            }
            break;

        case 'F':
            if ((String.Compare(json_string.getData(), 1, "irst", 0, 4, false) == 0) && (json_string.getData().Length == 5))
            {
                the_open_enum.in_known_list = true;
                the_open_enum.list_value    = TypeValueKnownValues.Value_First;
                goto open_enum_is_done;
            }
            break;

        case 'P':
            if ((String.Compare(json_string.getData(), 1, "remiumEconomy", 0, 13, false) == 0) && (json_string.getData().Length == 14))
            {
                the_open_enum.in_known_list = true;
                the_open_enum.list_value    = TypeValueKnownValues.Value_PremiumEconomy;
                goto open_enum_is_done;
            }
            break;

        default:
            break;
        }
        the_open_enum.in_known_list = false;
        the_open_enum.string_value  = json_string.getData();
        open_enum_is_done :;
        setValue(the_open_enum);
    }
示例#20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectDescriptor" /> class.
        /// </summary>
        /// <param name="objectValue">The object value.</param>
        /// <param name="type">The type of object.</param>
        /// <param name="unknownIndex">Index of the unknown.</param>
        public ObjectDescriptor(ObjectValue objectValue, TypeValue type, MemoryIndex unknownIndex)
        {
            Indexes = new ReadOnlyDictionary <string, MemoryIndex>(new Dictionary <string, MemoryIndex>());
            Type    = type;

            UnknownIndex = unknownIndex;

            ObjectValue = objectValue;
        }
示例#21
0
    public void setValue(TypeValueKnownValues new_value)
    {
        TypeValue new_full_value = new TypeValue();

        Debug.Assert(new_value != TypeValueKnownValues.Value__none);
        new_full_value.in_known_list = true;
        new_full_value.list_value    = new_value;
        setValue(new_full_value);
    }
示例#22
0
 /// <summary>
 /// Додавання напою
 /// </summary>
 /// <param name="id">ID</param>
 /// <param name="name">назва</param>
 /// <param name="price">ціна</param>
 /// <param name="size">розмів виміру мг/мл</param>
 /// <param name="type">тип виміру вага/об'єм</param>
 public SDrink(int id, string name, double price,
               double size, TypeValue type)
 {
     this.ID          = id;
     this.Name        = name;
     this.Price       = price;
     this.Size        = size;
     this.TypeOfValue = type;
 }
示例#23
0
        /// <inheritdoc />
        protected override void declareGlobal(TypeValue declaration)
        {
            var storage = getTypeStorage(declaration.QualifiedName.Name.LowercaseValue);

            var entry = readValue(storage);

            ReportMemoryEntryCreation();
            assign(storage, new MemoryEntry(declaration));
        }
示例#24
0
    private void  fromJSONValue(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONStringValue json_string = json_value.string_value();

        if (json_string == null)
        {
            throw new Exception("The value for field Value of SportsOlympicsGenderJSON is not a string.");
        }
        TypeValue the_open_enum = new TypeValue();

        switch (json_string.getData()[0])
        {
        case 'F':
            if ((String.Compare(json_string.getData(), 1, "emale", 0, 5, false) == 0) && (json_string.getData().Length == 6))
            {
                the_open_enum.in_known_list = true;
                the_open_enum.list_value    = TypeValueKnownValues.Value_Female;
                goto open_enum_is_done;
            }
            break;

        case 'M':
            switch (json_string.getData()[1])
            {
            case 'a':
                if ((String.Compare(json_string.getData(), 2, "le", 0, 2, false) == 0) && (json_string.getData().Length == 4))
                {
                    the_open_enum.in_known_list = true;
                    the_open_enum.list_value    = TypeValueKnownValues.Value_Male;
                    goto open_enum_is_done;
                }
                break;

            case 'i':
                if ((String.Compare(json_string.getData(), 2, "xed", 0, 3, false) == 0) && (json_string.getData().Length == 5))
                {
                    the_open_enum.in_known_list = true;
                    the_open_enum.list_value    = TypeValueKnownValues.Value_Mixed;
                    goto open_enum_is_done;
                }
                break;

            default:
                break;
            }
            break;

        default:
            break;
        }
        the_open_enum.in_known_list = false;
        the_open_enum.string_value  = json_string.getData();
        open_enum_is_done :;
        setValue(the_open_enum);
    }
示例#25
0
    private void  fromJSONValue(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONStringValue json_string = json_value.string_value();

        if (json_string == null)
        {
            throw new Exception("The value for field Value of SportsSeasonTypeJSON is not a string.");
        }
        TypeValue the_open_enum = new TypeValue();

        switch (json_string.getData()[0])
        {
        case 'P':
            switch (json_string.getData()[1])
            {
            case 'R':
                if ((String.Compare(json_string.getData(), 2, "E", 0, 1, false) == 0) && (json_string.getData().Length == 3))
                {
                    the_open_enum.in_known_list = true;
                    the_open_enum.list_value    = TypeValueKnownValues.Value_PRE;
                    goto open_enum_is_done;
                }
                break;

            case 'S':
                if ((String.Compare(json_string.getData(), 2, "T", 0, 1, false) == 0) && (json_string.getData().Length == 3))
                {
                    the_open_enum.in_known_list = true;
                    the_open_enum.list_value    = TypeValueKnownValues.Value_PST;
                    goto open_enum_is_done;
                }
                break;

            default:
                break;
            }
            break;

        case 'R':
            if ((String.Compare(json_string.getData(), 1, "EG", 0, 2, false) == 0) && (json_string.getData().Length == 3))
            {
                the_open_enum.in_known_list = true;
                the_open_enum.list_value    = TypeValueKnownValues.Value_REG;
                goto open_enum_is_done;
            }
            break;

        default:
            break;
        }
        the_open_enum.in_known_list = false;
        the_open_enum.string_value  = json_string.getData();
        open_enum_is_done :;
        setValue(the_open_enum);
    }
示例#26
0
 public override IEnumerable <FunctionValue> ResolveMethods(Value thisObject, TypeValue type, PHP.Core.QualifiedName methodName, IEnumerable <FunctionValue> objectMethods)
 {
     foreach (var method in objectMethods)
     {
         if (method.Name.Value == methodName.Name.Value)
         {
             yield return(method);
         }
     }
 }
        public DataContainerDefault(Array data, TConfig config) : base(data, config)
        {
            var parameters       = data.GetType().GetElementType();
            var constructorInfos = TypeValue.GetConstructor(new[] { parameters });

            if (constructorInfos == null)
            {
                throw new Exception($"Missing specific constructor of type {TypeValue} with parameters {parameters}");
            }
        }
 public DataContainerArray(Array data, TConfig config) : base(data, config)
 {
     // ReSharper disable once PossibleNullReferenceException
     if (!data.GetType().GetElementType().IsAssignableFrom(TypeValue.GetElementType()))
     {
         throw new ArgumentException(
                   $"Data structure of not {TypeValue} is not same type - {data.GetType().GetElementType()}"
                   );
     }
 }
 public void appendValue(TypeValue to_append)
 {
     if (!flagHasValue)
     {
         flagHasValue = true;
         storeValue.Clear();
     }
     Debug.Assert(flagHasValue);
     storeValue.Add(to_append);
 }
示例#30
0
 public GoogleContact()
 {
     Email1        = new TypeValue();
     Email2        = new TypeValue();
     Phone1        = new TypeValue();
     Phone2        = new TypeValue();
     Address1      = new Address();
     Website1      = new TypeValue();
     Organization1 = new Organization();
 }
示例#31
0
 public TypeInfo(TypeDescription typeDescription, Type type)
 {
     TypeDescriptions = typeDescription;
     Type = type;
     Type generic;
     if (type == null)
     {
         TypeValue = TypeValue.Null;
     }
     else if (type.IsPrimitive)
     {
         TypeValue = TypeValue.Primitive;
     }
     else if (type.IsArray)
     {
         TypeValue = TypeValue.Array;
     }
     else if (type.IsEnum)
     {
         TypeValue = TypeValue.Enum;
         EnumUnderlyingType = Enum.GetUnderlyingType(type);
     }
     else if (type == typeof(string))
     {
         TypeValue = TypeValue.String;
     }
     else if (typeof(IList).IsAssignableFrom(type))
     {
         TypeValue = TypeValue.List;
     }
     else if (typeof(IDictionary).IsAssignableFrom(type) && type.IsGenericType && ((generic = type.GetGenericArguments()[0]).IsPrimitive || generic.IsEnum || generic == typeof(string)))
     {
         TypeValue = TypeValue.Dictionary;
     }
     else
     {
         TypeValue = TypeValue.Object;
         Fields = type.GetFields(BindingFlags.Instance | BindingFlags.GetField | BindingFlags.SetField | BindingFlags.Public);
         var count = Fields.Length;
         _fields = new Dictionary<string, FieldInfo>(count);
         FieldInfo field;
         for (int i = 0; i < count; i++)
         {
             field = Fields[i];
             _fields.Add(field.Name, field);
         }
     }
 }
示例#32
0
        internal void TS_FindAttributes(IDictionary attributes, TypeValue typeValue, bool backward, FindResults FindResults, Type expectedException, CheckType checkType)
        {
            int errorCount = 0;
            bool isEqual = false;
            string text = "";
            AutomationTextAttribute key = null;    // key / name of attribute
            object valueToFind = null;    // Value to perform FindAttribute on
            TextPatternRange callingRange = null;   // Range to do FindAttribute on, default to entire document
            TextPatternRange findRange = null;    // Range FindAttribute returns
            IDictionaryEnumerator enum1 = attributes.GetEnumerator(); // Enumerate through the dictionary

            callingRange = Pattern_DocumentRange(checkType);

            // Bug1134056: RichEdit oddness again. We can't just use the entire document range.
            TextLibrary.TrimRangeCRLF(m_le, callingRange);

            // Enumerate through attributes
            while (enum1.MoveNext())
            {
                string keyString = "";

                // get key and value for this attribute
                key = (AutomationTextAttribute)enum1.Key;
                keyString = Helpers.GetProgrammaticName(key);

                if (enum1.Value == TextPattern.MixedAttributeValue) // Try to get a smaller range for a non-mixed attribute value
                {
                    Comment("Range has mixed attribute value for attribute " + keyString + ". Tryig to create single-character range to determine non-mixed attribute");

                    // Limit range to first character so we should get CONSISTENT attribute value(!)
                    CreateEmptyRange(out callingRange, RangeLocation.Start, checkType);
                    Range_ExpandToEnclosingUnit(callingRange, TextUnit.Character, null, checkType);

                    Range_GetAttributeValue(callingRange, (AutomationTextAttribute)enum1.Key, ref valueToFind, null, checkType);

                    if (valueToFind == TextPattern.MixedAttributeValue)
                    {
                        ThrowMe(checkType, "Single character range should(!) not have a mixed attribute value for attribute " + keyString + ". (International Locale perhaps?)");
                    }
                }
                else if (enum1.Value == AutomationElement.NotSupported)
                {
                    Comment("Attribute " + keyString + " is not supported, skipping...");
                    continue;
                }
                else
                {
                    valueToFind = enum1.Value;
                }

                SetValue(typeValue, key, ref valueToFind); // cast to correct type

                string msg = "FindAttribute(" + keyString + "," +
                        (valueToFind != null ? valueToFind.ToString() : "NULL") + "," +
                        (backward == true ? "backwards" : "forwards") +
                        ")";

                // Finally, find the attribute value(!)
                Range_FindAttribute(callingRange, ref findRange, (AutomationTextAttribute)enum1.Key, valueToFind, backward,
                                    expectedException, checkType);

                // Did we get correct results?
                switch (FindResults)
                {
                    case FindResults.Exception:
                        if (expectedException == null)
                            ThrowMe(checkType, "Test code error, null expected exception is incorrect when getresult = " + Parse(FindResults, expectedException));
                        break;                  // actually takes place in Range_FindAttribute
                    case FindResults.MatchingRange:
                        if (findRange == null)
                        {
                            Comment(KNOWNISSUE + msg + " returned null range. Expected non-null range");
                            errorCount++;
                        }
                        else
                        {


                            Range_Compare(callingRange, findRange, ref isEqual, null, checkType);
                            if (isEqual == false)
                            {
                                string callingText = "", findText = "";
                                Comment(KNOWNISSUE + "Comparison failed. Expected calling and actual range to have matching text");
                                Range_GetText(callingRange, ref callingText, -1, null, checkType);
                                Comment("Calling range text = '" + TrimText(callingText, 512) + "'");
                                Range_GetText(findRange, ref findText, -1, null, checkType);
                                Comment("Actual  range text = '" + TrimText(findText, 512) + "'");
                                errorCount++;
                            }
                        }
                        break;
                    case FindResults.EmptyRange:
                        if (findRange == null)
                        {
                            Comment(KNOWNISSUE + msg + " returned null range. Expected non-null range");
                            errorCount++;
                        }
                        else
                        {
                            Range_GetText(findRange, ref text, -1, null, checkType);
                            if (text.Length != 0)
                            {
                                Comment(KNOWNISSUE + msg + " returned non-zero length text for range. Expected zero-length" +
                                        ", text = '" + TrimText(Range_GetText(findRange), 512) + "'");
                                errorCount++;
                            }
                        }
                        break;
                    case FindResults.Null:
                        if (findRange != null)
                        {
                            if (key == TextPattern.TabsAttribute)
                            {
                                // This test condition failure is only really valid for this attribute
                                // if we have a control with a non-zero length array of tab marks
                                if (((double[])valueToFind).Length == 0)
                                    continue; // skip to next attribute
                            }
                            Comment(KNOWNISSUE + msg + " returned non-null range, expected null for attribute " +
                                    keyString +
                                    ", text = '" + TrimText(Range_GetText(findRange), 512) + "'");
                            errorCount++;
                        }
                        break;
                    default:
                        throw new ArgumentException("TS_FindAttributes() has no support for " + ParseType(FindResults));
                }
            }
            if (errorCount == 0)
                Comment("FindAttribute(...) returned the correct range (" + ParseType(FindResults) + ")");
            else
                ThrowMe(checkType, "FindAttribute(...) returned " + errorCount + " incorrect results");

            m_TestStep++;
        }
 public ScriptOffsetInfo()
 {
     list = ListValue.Null; type = TypeValue.None; index = -1;
 }
 public TypeSerialization Get(TypeValue type)
 {
     return _serializations[(int)type];
 }
示例#35
0
        //---------------------------------------------------------------------------
        // Helper for FindAttribute() test cases
        //---------------------------------------------------------------------------
        internal void FindAttributeHelper(SampleText sampleText, TypeValue typeValue, AttributeType attribType, bool backward, FindResults FindResults, Type expectedException)
        {
            bool isConsistentAttributes;
            IDictionary attributes = null;
            TextPatternRange documentRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Identify & use <<attribType>> attributes
            documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration);
            TS_GetAttributeValues(documentRange, out attributes, attribType, CheckType.Verification);

            // Pre-Condition Identify if document has consistent attribute values
            TS_VerifyAttributeRanges(attributes, out isConsistentAttributes);

            // Pre-Condition For each attribute, Val argument has <<typeValue>> type and <<typeValue>> value
            TS_SetAttributeValues(ref attributes, typeValue);

            // Call FindAttribute(<<backward>>) without errors (<<FindResults>>)/with <<expectedException, if not null>>
            TS_FindAttributes(attributes, typeValue, backward, FindResults, expectedException, CheckType.Verification);
        }
示例#36
0
        static internal void SetValue(TypeValue typeValue, AutomationTextAttribute key, ref object value)
        {
            switch (typeValue)
            {
                case TypeValue.MatchesTypeAndValue:                      // CORRECT type and value
                case TypeValue.WrongValue:                               // CORRECT type: INCORRECT value
                case TypeValue.WrongEnumValue:                           // Incorrect enum value
                    break; // Do nothing, casts that follow below will work
                case TypeValue.Null:                                     // NULL
                case TypeValue.WrongTypeAndValue:                        // INCORRECT type and value
                case TypeValue.WrongType:                                // INCORRECT type: CORRECT value
                    // no casts, we're done, type is handled elsewhere
                    return;
                default:
                    throw new ArgumentException("No support for " + ParseType(typeValue));
            }

            // Switch statement requires integral types, have to use a massive if-else instead.
            if (key == TextPattern.AnimationStyleAttribute)
            {
                value = (AnimationStyle)value;
            }
            else if ((key == TextPattern.IsHiddenAttribute)
                  || (key == TextPattern.IsItalicAttribute)
                  || (key == TextPattern.IsReadOnlyAttribute)
                  || (key == TextPattern.IsSubscriptAttribute)
                  || (key == TextPattern.IsSuperscriptAttribute))
            {
                value = (bool)value;
            }
            else if (key == TextPattern.BulletStyleAttribute)
            {
                value = (BulletStyle)value;
            }
            else if (key == TextPattern.CapStyleAttribute)
            {
                value = (CapStyle)value;
            }
            else if (key == TextPattern.CultureAttribute)
            {
                value = (CultureInfo)value;
            }
            else if ((key == TextPattern.FontSizeAttribute)
                  || (key == TextPattern.IndentationFirstLineAttribute)
                  || (key == TextPattern.IndentationLeadingAttribute)
                  || (key == TextPattern.IndentationTrailingAttribute)
                  || (key == TextPattern.MarginBottomAttribute)
                  || (key == TextPattern.MarginLeadingAttribute)
                  || (key == TextPattern.MarginTopAttribute)
                  || (key == TextPattern.MarginTrailingAttribute))
            {
                value = (double)value;
            }
            else if (key == TextPattern.TabsAttribute)
            {
                value = (double[])value;
            }
            else if (key == TextPattern.TextFlowDirectionsAttribute)
            {
                value = (FlowDirections)value;
            }
            else if (key == TextPattern.HorizontalTextAlignmentAttribute)
            {
                value = (HorizontalTextAlignment)value;
            }
            else if ((key == TextPattern.BackgroundColorAttribute)
                  || (key == TextPattern.FontWeightAttribute)
                  || (key == TextPattern.ForegroundColorAttribute)
                  || (key == TextPattern.StrikethroughColorAttribute)
                  || (key == TextPattern.UnderlineColorAttribute)
                  || (key == TextPattern.OverlineColorAttribute))
            {
                value = (int)value;
            }
            else if (key == TextPattern.OutlineStylesAttribute)
            {
                value = (OutlineStyles)value;
            }
            else if (key == TextPattern.FontNameAttribute)
            {
                value = (string)value;
            }
            else if ((key == TextPattern.OverlineStyleAttribute)
                  || (key == TextPattern.StrikethroughStyleAttribute)
                  || (key == TextPattern.UnderlineStyleAttribute))
            {
                value = (TextDecorationLineStyle)value;
            }
            else
            {
                throw new ArgumentException("SetValue() has no support for AutomationTextAttribute " + Helpers.GetProgrammaticName(key));
            }
        }
示例#37
0
        static internal void TS_SetAttributeValues(ref IDictionary attributes, TypeValue typeValue)
        {
            float f = 0; // A type that no attribute uses as of 7/7/05
            IDictionary newAttribs = new Hashtable(attributes.Count);
            IDictionaryEnumerator enum1 = null;
            AutomationTextAttribute key = null;
            object value = null;

            enum1 = attributes.GetEnumerator();

            if (typeValue == TypeValue.MatchesTypeAndValue) // i.e. we already have everything we need
            {
                Comment("Default Attribute values and type are correct for this test");
            }
            else
            {
                for (int i = 0; i < attributes.Count; i++)
                {
                    enum1.MoveNext();
                    key = (AutomationTextAttribute)enum1.Key;
                    value = enum1.Value;

                    // Strictly speaking, its not necessary to add the key/value within each case statement
                    // but for clarity, i.e. making it clear what (if anything) is done to the value variable
                    switch (typeValue)
                    {
                        case TypeValue.Null:                                     // NULL
                            newAttribs.Add(key, null);
                            break;
                        case TypeValue.WrongTypeAndValue:                           // INCORRECT type and value
                            newAttribs.Add(key, f);
                            break;
                        case TypeValue.WrongType:                                // INCORRECT type: CORRECT value
                            SetWrongType(ref value);
                            newAttribs.Add(key, value);
                            break;
                        case TypeValue.WrongValue:                               // CORRECT type: INCORRECT value
                        case TypeValue.WrongEnumValue:                           // Incorrect enum value
                            SetWrongValue(ref value, key);
                            newAttribs.Add(key, value);
                            break;
                        default:
                            throw new ArgumentException("TS_SetAttributeValues has no support for " + ParseType(typeValue));
                    }
                }

                // Delete existing attribute library and rebuild it
                attributes.Clear();
                enum1 = newAttribs.GetEnumerator();

                for (int i = 0; i < newAttribs.Count; i++)
                {
                    enum1.MoveNext();
                    key = (AutomationTextAttribute)enum1.Key;
                    value = enum1.Value;

                    attributes.Add(key, value);
                }

                Comment("Modified dictionary of known attribute values to be " + Parse(typeValue));
            }

            m_TestStep++;
        }
示例#38
0
 /// ---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(TypeValue value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
 public ScriptOffsetInfo(ListValue l, TypeValue t, int i)
 {
     list = l;
     type = t;
     index = i;
 }
示例#40
0
 static public string Parse(TypeValue value)
 {
     switch (value)
     {
         case TypeValue.MatchesTypeAndValue: return "CORRECT type and value";
         case TypeValue.WrongType: return "INCORRECT type, CORRECT value";
         case TypeValue.WrongValue: return "CORRECT type, INCORRECT value";
         case TypeValue.WrongTypeAndValue: return "INCORRECT type and value";
         case TypeValue.Null: return "NULL";
         case TypeValue.WrongEnumValue: return "Incorrect enum value";
         default:
             throw new ArgumentException("Parse() has no support for " + ParseType(value));
     }
 }