public VariantReference(object value)
 {
     if(value == null)
     {
         _value = null;
         _type = VariantType.Null;
     }
     else
     {
         var tp = value.GetType();
         if (!AcceptableType(tp)) throw new System.ArgumentException(string.Format("The Type of the value '{0}' is not supported by VariantReference.", tp.FullName), "value");
         _value = value;
         _type = GetVariantType(tp);
     }
 }
Example #2
0
 public void SetValue(byte[] v)
 {
     _type           = VariantType.ByteString;
     _valueByteArray = v;
     _valueString    = null;
     _valueBitStream = null;
 }
Example #3
0
 protected VariantSymbol(VariantType type, Element def = null)
 {
     VariantType = type;
     DefaultValue = def;
     AppendChild(DefaultValue);
     IsInitialize = true;
 }
Example #4
0
 public Variant(VariantType type, ReadOnlyMemory <char> key)
 {
     Type      = type;
     Key       = key;
     Value     = new Pattern();
     IsDefault = false;
 }
Example #5
0
 public void SetValue(string v)
 {
     _type           = VariantType.String;
     _valueString    = v;
     _valueBitStream = null;
     _valueByteArray = null;
 }
Example #6
0
        //public void SetValue(byte[] v)
        //{
        //    _type = VariantType.ByteString;
        //    _valueByteArray = v;
        //    _valueString = null;
        //    _valueBitStream = null;
        //}

        public void SetValue(BitwiseStream v)
        {
            _type           = VariantType.BitStream;
            _valueBitStream = v;
            _valueString    = null;
            _valueByteArray = null;
        }
Example #7
0
 public void SetValue(bool v)
 {
     _type           = VariantType.Boolean;
     _valueBool      = v;
     _valueString    = null;
     _valueByteArray = null;
 }
        private VariantReference(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            _valueReference = null;
            _unityObjectReference = null;

            _type = (VariantType)info.GetInt32("type");
            switch (_type)
            {
                case VariantType.Object:
                case VariantType.GameObject:
                case VariantType.Component:
                    //do nothing
                    break;
                case VariantType.Vector2:
                case VariantType.Vector3:
                case VariantType.Quaternion:
                case VariantType.Color:
                    var arr = StringUtil.SplitFixedLength(info.GetString("vector"), ",", 4);
                    //_vectorStore = new Vector4(ConvertUtil.ToSingle(arr[0]),
                    //                           ConvertUtil.ToSingle(arr[1]),
                    //                           ConvertUtil.ToSingle(arr[2]),
                    //                           ConvertUtil.ToSingle(arr[3]));
                    break;
                default:
                    _valueReference = info.GetString("value");
                    break;
            }
            (this as ISerializationCallbackReceiver).OnAfterDeserialize();
        }
Example #9
0
        /// <summary>
        /// Returns true if a Variant <see cref="GameObject"/> <paramref name="modelGameObject"/> is available,
        /// otherwise returns false. If true and the matching <see cref="GameObject"/> <paramref name="modelGameObject"/>
        /// has not been instantiated yet, it will be instantiated and cached.
        /// </summary>
        /// <param name="variantType"></param>
        /// <param name="modelGameObject"></param>
        /// <returns></returns>
        private bool TryGetVariant(VariantType variantType, out GameObject modelGameObject)
        {
            modelGameObject = null;
            var foundVariantModel = false;

            for (var i = 0; i < _variantWearableModels.Length; i++)
            {
                var wmi = _variantWearableModels[i];
                if (wmi.variantType == variantType)
                {
                    foundVariantModel = true;

                    if (!_wearableGameObjectsByProductVariant.TryGetValue(variantType, out modelGameObject))
                    {
                        var newModelGameObject = CreateWearableModel(wmi.displayModel);

                        _wearableGameObjectsByProductVariant.Add(wmi.variantType, newModelGameObject);

                        modelGameObject = newModelGameObject;
                    }

                    break;
                }
            }

            return(foundVariantModel);
        }
Example #10
0
        private void determinePolymorphicType()
        {
            type = null;

            // do a pairwise comparison of all alleles against the reference allele
            foreach (Allele allele in alleles)
            {
                if (allele == REF)
                {
                    continue;
                }

                // find the type of this allele relative to the reference
                VariantType biallelicType = typeOfBiallelicVariant(REF, allele);

                // for the first alternate allele, set the type to be that one
                if (type == null)
                {
                    type = biallelicType;
                }
                // if the type of this allele is different from that of a previous one, assign it the MIXED type and quit
                else if (biallelicType != type)
                {
                    type = VariantType.MIXED;
                    return;
                }
            }
        }
Example #11
0
 public RnaEdit(int start, int end, string bases)
 {
     Start = start;
     End   = end;
     Bases = bases;
     Type  = VariantType.unknown;
 }
Example #12
0
 public MitoMapSvItem(IChromosome chromosome, int start, int end, VariantType variantType)
 {
     Chromosome  = chromosome;
     Start       = start;
     End         = end;
     VariantType = variantType;
 }
Example #13
0
        /// <summary>Parse string using the specified value type and return the resulting variant.</summary>
        public static Variant Parse(VariantType valueType, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                // Empty value
                return(new Variant());
            }
            else
            {
                // Switch on type of default value
                switch (valueType)
                {
                case VariantType.String:
                    return(new Variant(value));

                case VariantType.Double:
                    double doubleResult = double.Parse(value);
                    return(new Variant(doubleResult));

                case VariantType.Bool:
                    bool boolResult = bool.Parse(value);
                    return(new Variant(boolResult));

                case VariantType.Int:
                    int intResult = int.Parse(value);
                    return(new Variant(intResult));

                case VariantType.Long:
                    long longResult = long.Parse(value);
                    return(new Variant(longResult));

                case VariantType.LocalDate:
                    LocalDate dateResult = LocalDateUtil.Parse(value);
                    return(new Variant(dateResult));

                case VariantType.LocalTime:
                    LocalTime timeResult = LocalTimeUtil.Parse(value);
                    return(new Variant(timeResult));

                case VariantType.LocalMinute:
                    LocalMinute minuteResult = LocalMinuteUtil.Parse(value);
                    return(new Variant(minuteResult));

                case VariantType.LocalDateTime:
                    LocalDateTime dateTimeResult = LocalDateTimeUtil.Parse(value);
                    return(new Variant(dateTimeResult));

                case VariantType.Instant:
                    Instant instantResult = InstantUtil.Parse(value);
                    return(new Variant(instantResult));

                case VariantType.Enum:
                    throw new Exception("Variant cannot be created as enum without specifying enum typename.");

                default:
                    // Error message if any other type
                    throw new Exception("Unknown value type when parsing string into variant.");
                }
            }
        }
Example #14
0
        // VARENUMs that are VARIANT only (e.g. not valid for PROPVARIANT)
        //
        //  VT_DISPATCH
        //  VT_UNKNOWN
        //  VT_DECIMAL
        //  VT_UINT
        //  VT_ARRAY
        //  VT_BYREF

        public override object?GetData()
        {
            VariantType propertyType = RawVariantType;

            if ((propertyType & VariantType.ByRef) != 0 ||
                (propertyType & VariantType.Array) != 0)
            {
                // Not legit for PROPVARIANT
                throw new InvalidOleVariantTypeException();
            }

            if ((propertyType & VariantType.Vector) != 0)
            {
                throw new NotImplementedException();
            }

            propertyType &= VariantType.TypeMask;

            switch (propertyType)
            {
            case VariantType.IDispatch:
            case VariantType.IUnknown:
            case VariantType.Decimal:
            case VariantType.UnsignedInteger:
                throw new InvalidOleVariantTypeException();
            }

            return(base.GetData());
        }
Example #15
0
        /// <summary>
        /// Returns true if a background and model sprite was found for the passed
        /// <paramref name="productType"/> and <paramref name="variantType"/>, otherwise false.
        /// </summary>
        public bool TryGetProductImages(
            ProductType productType,
            VariantType variantType,
            out WearableProductImage productImage)
        {
            if (!_isSetup)
            {
                Setup();
            }

            productImage = _fallbackBackgroundImage;

            WearableVariantImageMapping variantMapping;
            WearableProductImageMapping productMapping;

            if (_variantImageLookup.TryGetValue(variantType, out variantMapping))
            {
                productImage = variantMapping;
            }
            else if (_productImageLookup.TryGetValue(productType, out productMapping))
            {
                productImage = productMapping;
            }

            return(productImage != null);
        }
Example #16
0
        public void Variant_Set()
        {
            const int         expectedStart      = 100;
            const int         expectedEnd        = 102;
            const string      expectedRef        = "AT";
            const string      expectedAlt        = "";
            const VariantType expectedType       = VariantType.deletion;
            const string      expectedVid        = "1:100:A:C";
            const bool        expectedRefMinor   = true;
            const bool        expectedDecomposed = false;
            const bool        expectedRecomposed = true;
            var expectedLinkedVids = new[] { "1:102:T:G" };
            var expectedBehavior   = AnnotationBehavior.SmallVariants;

            var variant = new Variant(ChromosomeUtilities.Chr1, expectedStart, expectedEnd, expectedRef, expectedAlt,
                                      expectedType, expectedVid, expectedRefMinor, expectedDecomposed, expectedRecomposed, expectedLinkedVids,
                                      expectedBehavior, false);

            Assert.Equal(ChromosomeUtilities.Chr1, variant.Chromosome);
            Assert.Equal(expectedStart, variant.Start);
            Assert.Equal(expectedEnd, variant.End);
            Assert.Equal(expectedRef, variant.RefAllele);
            Assert.Equal(expectedAlt, variant.AltAllele);
            Assert.Equal(expectedType, variant.Type);
            Assert.Equal(expectedVid, variant.VariantId);
            Assert.Equal(expectedRefMinor, variant.IsRefMinor);
            Assert.Equal(expectedDecomposed, variant.IsDecomposed);
            Assert.Equal(expectedRecomposed, variant.IsRecomposed);
            Assert.Equal(expectedLinkedVids, variant.LinkedVids);
            Assert.Equal(expectedBehavior, variant.Behavior);
        }
        private static string GetVid(string ensemblName, int start, int end, VariantType variantType,
                                     IReadOnlyList <IBreakEnd> breakEnds)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (variantType)
            {
            case VariantType.insertion:
                return($"{ensemblName}:{start}:{end}:INS");

            case VariantType.deletion:
                return($"{ensemblName}:{start}:{end}");

            case VariantType.duplication:
                return($"{ensemblName}:{start}:{end}:DUP");

            case VariantType.tandem_duplication:
                return($"{ensemblName}:{start}:{end}:TDUP");

            case VariantType.translocation_breakend:
                return(breakEnds?[0].ToString());

            case VariantType.inversion:
                return($"{ensemblName}:{start}:{end}:Inverse");

            case VariantType.mobile_element_insertion:
                return($"{ensemblName}:{start}:{end}:MEI");

            default:
                return($"{ensemblName}:{start}:{end}");
            }
        }
Example #18
0
        public void Elongation(VariantType variantType, OverlapType overlapType, EndpointOverlapType endpointOverlapType, bool expectedResult)
        {
            var  featureEffect  = new FeatureVariantEffects(overlapType, endpointOverlapType, false, variantType, true);
            bool observedResult = featureEffect.Elongation();

            Assert.Equal(expectedResult, observedResult);
        }
        private bool TestVariant(VcfReader vr, VariantType type1, VariantType type2)
        {
            var testVar = new VcfVariant();

            vr.GetNextVariant(testVar);
            return((testVar.VarType1 == type1) && (testVar.VarType2 == type2));
        }
Example #20
0
 public PipelineCreator(
     IParserDefinition definition,
     WriterConfiguration config,
     VariantType variant
     )
 {
     _definition            = definition;
     _configuration         = config;
     _variant               = variant;
     _singleWriterExecution = new ExecutionDataflowBlockOptions {
         MaxDegreeOfParallelism = 1
     };
     _options = new ExecutionDataflowBlockOptions {
         MaxDegreeOfParallelism = Environment.ProcessorCount,
         BoundedCapacity        = 1000000,
         MaxMessagesPerTask     = 10000
     };
     _linkOptions = new DataflowLinkOptions {
         PropagateCompletion = true
     };
     _plDictionary     = new Dictionary <string, HierarchyNode>();
     _hierarchyRoot    = new HPEHierarchyNode();
     _csvOutputWriter  = new CsvOutputWriter(config);
     _jsonOutputWriter = new JsonOutputWriter(config);
 }
Example #21
0
        /// <summary>
        /// determines the flanking variant's functional consequence
        /// </summary>
        public void DetermineFlankingVariantEffects(bool isDownstreamVariant, VariantType internalCopyNumberType)
        {
            // add the appropriate flanking variant consequence
            _consequences.Add(isDownstreamVariant
                ? ConsequenceType.DownstreamGeneVariant
                : ConsequenceType.UpstreamGeneVariant);

            // FeatureElongation
            if (_variantEffect.HasTranscriptElongation())
            {
                _consequences.Add(ConsequenceType.FeatureElongation);
            }

            // TranscriptTruncation
            if (_variantEffect.HasTranscriptTruncation())
            {
                _consequences.Add(ConsequenceType.TranscriptTruncation);
            }

            // CopyNumber
            if (internalCopyNumberType != VariantType.unknown)
            {
                AssignCnvTypes(internalCopyNumberType);
            }
        }
Example #22
0
        public void Variant_Set()
        {
            var               expectedChromosome = new Chromosome("chr1", "1", 0);
            const int         expectedStart      = 100;
            const int         expectedEnd        = 102;
            const string      expectedRef        = "AT";
            const string      expectedAlt        = "";
            const VariantType expectedType       = VariantType.deletion;
            const string      expectedVid        = "1:100:A:C";
            const bool        expectedRefMinor   = true;
            const bool        expectedDecomposed = false;
            const bool        expectedRecomposed = true;
            var               expectedLinkedVids = new[] { "1:102:T:G" };
            var               expectedBreakEnds  = new IBreakEnd[] { new BreakEnd(expectedChromosome, expectedChromosome, 100, 200, false, false) };
            var               expectedBehavior   = new AnnotationBehavior(false, false, false, false, true);

            var variant = new Variant(expectedChromosome, expectedStart, expectedEnd, expectedRef, expectedAlt,
                                      expectedType, expectedVid, expectedRefMinor, expectedDecomposed, expectedRecomposed, expectedLinkedVids,
                                      expectedBreakEnds, expectedBehavior);

            Assert.Equal(expectedChromosome, variant.Chromosome);
            Assert.Equal(expectedStart, variant.Start);
            Assert.Equal(expectedEnd, variant.End);
            Assert.Equal(expectedRef, variant.RefAllele);
            Assert.Equal(expectedAlt, variant.AltAllele);
            Assert.Equal(expectedType, variant.Type);
            Assert.Equal(expectedVid, variant.VariantId);
            Assert.Equal(expectedRefMinor, variant.IsRefMinor);
            Assert.Equal(expectedDecomposed, variant.IsDecomposed);
            Assert.Equal(expectedRecomposed, variant.IsRecomposed);
            Assert.Equal(expectedLinkedVids, variant.LinkedVids);
            Assert.Equal(expectedBreakEnds, variant.BreakEnds);
            Assert.Equal(expectedBehavior, variant.Behavior);
        }
Example #23
0
        public ProductRoot CreateProductRoot(string file, ParseState state, VariantType variantType)
        {
            var specificationsLabeledItems = CreateSpecificationsLabeledItems(state);

            if (string.IsNullOrEmpty(state.PartNumber))
            {
                Console.WriteLine(state.File);
            }

            var productRoot = CreateProductRoot(
                file,
                state,
                CreateProduct(state, GetHpeHierarchyNode(state), state.Branch, GetProductLineHierarchyNode(state)),
                CreateBranch(state, variantType),
                CreateProductVariants(state),
                CreateMarketing(state),
                CreateOptionsItems(state),
                specificationsLabeledItems,
                ImageSelector.FilterImages(state.Links.ImageLinks),
                state.Hierarchy,
                CreateDetail(state, specificationsLabeledItems, state.Product.Unspsc)
                );

            return(productRoot);
        }
Example #24
0
File: Runner.cs Project: fhelje/HPE
        protected async Task Import(WriterConfiguration config, IParserDefinition parserDefinition,
                                    VariantType variant)
        {
            var sw = new Stopwatch();

            sw.Start();
            const FileTypes fileTypes = FileTypes.Detail
                                        | FileTypes.Link
                                        | FileTypes.Marketing
                                        | FileTypes.Option
                                        | FileTypes.Option
                                        | FileTypes.Product
                                        | FileTypes.Specification
                                        | FileTypes.Supplier
                                        | FileTypes.Json;

            FileHelpers.DeleteExistingFiles(fileTypes, config);
            Console.WriteLine("Deleting files");

            var(pipeline, targetTask) = new PipelineCreator(parserDefinition, config, variant).CreatePipeline();
            await pipeline.SendAsync(config).ConfigureAwait(false);

            pipeline.Complete();
            await targetTask.ContinueWith(_ => {
                sw.Stop();
                Console.WriteLine($"Done in {sw.Elapsed.ToString()}");
            }).ConfigureAwait(false);

            Console.ReadLine();
        }
Example #25
0
        [InlineData(VariantType.run_of_homozygosity, false)]           // no change
        public void NeedsTranscriptVariant_NoConsequences_EvaluateByVariantType(VariantType variantType, bool expectedResult)
        {
            var  consequences   = new List <ConsequenceTag>();
            bool observedResult = Consequences.NeedsTranscriptVariant(variantType, consequences);

            Assert.Equal(expectedResult, observedResult);
        }
Example #26
0
        public string GetJsonString()
        {
            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            jsonObject.AddStringValue("chromosome", Chromosome.EnsemblName);
            jsonObject.AddIntValue("begin", Start);
            jsonObject.AddIntValue("end", End);
            jsonObject.AddStringValue("variantType", VariantType.ToString());
            jsonObject.AddStringValue("id", Id);
            jsonObject.AddStringValue("clinicalInterpretation", GetClinicalDescription(ClinicalInterpretation));
            jsonObject.AddStringValues("phenotypes", Phenotypes);
            jsonObject.AddStringValues("phenotypeIds", PhenotypeIds);
            if (ObservedGains > 0)
            {
                jsonObject.AddIntValue("observedGains", ObservedGains);
            }
            if (ObservedLosses > 0)
            {
                jsonObject.AddIntValue("observedLosses", ObservedLosses);
            }
            jsonObject.AddBoolValue("validated", Validated);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Example #27
0
        /// <summary>
        /// Populate by parsing multi-line CSV text using the specified
        /// matrix layout and an array of column parser functions.
        ///
        /// If the data has more columns than the array of parsers,
        /// the last parser in the array is used for all additional
        /// columns. This permits ingesting CSV files with an unknown
        /// number of value columns of the same type, after an initial
        /// set of category columns that have other types.
        ///
        /// The specified parser is not used for row and column headers
        /// which are always dot delimited strings.
        /// </summary>
        public void ParseCsv(MatrixLayout layout, VariantType[] colTypes, string csvText)
        {
            // Create and populate an array of column parser functions
            var parsers = new Func <string, object> [colTypes.Length];

            for (int i = 0; i < parsers.Length; i++)
            {
                // It is important to copy and pass ValueType by value
                // rather than as array and element index, because the
                // array may change by the time the expression is invoked
                VariantType colType = colTypes[i];
                parsers[i] = value => Variant.Parse(colType, value).Value;
            }

            // Parse CSV text
            ParseCsv(layout, parsers, csvText);

            // Populate the array of column value types using the actual matrix size,
            // padding with the last value of the argument array
            ColTypes = new VariantType[ColCount];
            for (int i = 0; i < ColTypes.Length; i++)
            {
                if (i < colTypes.Length)
                {
                    ColTypes[i] = colTypes[i];
                }
                else
                {
                    ColTypes[i] = colTypes[colTypes.Length - 1];
                }
            }
        }
Example #28
0
 private Variant(ValuesVariant val, string str, byte size, VariantType variantType)
 {
     this.val         = val;
     this.str         = str;
     this.size        = size;
     this.variantType = variantType;
 }
Example #29
0
 public void Recycle()
 {
     (Value as VariantMap)?.Recycle();
     Value     = null;
     ValueType = VariantType.Null;
     this.ReturnPool();
 }
Example #30
0
 public Variant(Variant variant) : this()
 {
     type = variant.type;
     this.Set(variant.Get());
     //var getFunc = typeof(Variant).GetMethod("Get").MakeGenericMethod(Type.Convert());
     //this.Set(getFunc.Invoke(null, new object[] { variant }));
 }
Example #31
0
        // VARENUMs that are VARIANT only (e.g. not valid for PROPVARIANT)
        //
        //  VT_DISPATCH
        //  VT_UNKNOWN
        //  VT_DECIMAL
        //  VT_UINT
        //  VT_ARRAY
        //  VT_BYREF
        //
        protected virtual unsafe object?GetCoreType(VariantType propertyType, void *data)
        {
            switch (propertyType)
            {
            case VariantType.Int32:
            case VariantType.Integer:
            case VariantType.Error:     // SCODE
                return(*((int *)data));

            case VariantType.UInt32:
            case VariantType.UnsignedInteger:
                return(*((uint *)data));

            case VariantType.Int16:
                return(*((short *)data));

            case VariantType.UInt16:
                return(*((ushort *)data));

            case VariantType.SignedByte:
                return(*((sbyte *)data));

            case VariantType.UnsignedByte:
                return(*((byte *)data));

            case VariantType.Currency:     // Currency (long long)
                return(*((long *)data));

            case VariantType.Single:
                return(*((float *)data));

            case VariantType.Double:
                return(*((double *)data));

            case VariantType.Decimal:
                return((*((DECIMAL *)data)).ToDecimal());

            case VariantType.Boolean:
                // VARIANT_TRUE is -1
                return(*((short *)data) == -1);

            case VariantType.BasicString:
                return(Marshal.PtrToStringBSTR((IntPtr)(*((void **)data))));

            case VariantType.Variant:
                return(new Variant(new IntPtr(*((void **)data)), ownsHandle: false));

            case VariantType.Date:
                return(Conversion.VariantDateToDateTime(*((double *)data)));

            case VariantType.Record:
            case VariantType.IDispatch:
            case VariantType.IUnknown:
                throw new NotImplementedException();

            default:
                return(s_UnsupportedObject);
            }
        }
Example #32
0
 protected VariantSymbol(TextPosition tp, VariantType type, Element def = null)
     : base(tp)
 {
     VariantType = type;
     DefaultValue = def;
     AppendChild(DefaultValue);
     IsInitialize = true;
 }
Example #33
0
 public void SetValue(double v)
 {
     _type           = VariantType.Double;
     _valueDouble    = v;
     _valueString    = null;
     _valueBitStream = null;
     _valueByteArray = null;
 }
Example #34
0
 public void SetValue(int v)
 {
     _type           = VariantType.Int;
     _valueInt       = v;
     _valueString    = null;
     _valueBitStream = null;
     _valueByteArray = null;
 }
Example #35
0
 public Variant(object o)
 {
     if(o is bool)
     {
         oValue = (bool)o;
         varType = VariantType.vtBool;
         return;
     }
     if(o is int)
     {
         oValue = (int)o;
         varType = VariantType.vtInt;
         return;
     }
     if(o is double)
     {
         oValue = (double)o;
         varType = VariantType.vtDouble;
         return;
     }
     if(o is DateTime)
     {
         oValue = (DateTime)o;
         varType = VariantType.vtDateTime;
         return;
     }
     if(o is string)
     {
         oValue = (string)o;
         varType = VariantType.vtString;
         return;
     }
     if(o is Variant)
     {
         oValue = ((Variant)o).oValue;
         varType = ((Variant)o).VarType;
         return;
     }
     if(o is System.Decimal)
     {
         oValue = (int)(decimal)o;
         varType = VariantType.vtInt;
         return;
     }
     if(o is long)
     {
         oValue = (int)(long)o;
         varType = VariantType.vtInt;
         return;
     }
     if(o is float)
     {
         oValue = (double)(float)o;
         varType = VariantType.vtDouble;
         return;
     }
     throw(new CalcException("Invalid object type for Variant conversion"));
 }
 public VariantDeclaration(TextPosition tp, VariantType type, string name, TupleLiteral attr, Element expli, Element def = null)
     : base(tp, type, def)
 {
     Name = name;
     AttributeAccess = attr;
     ExplicitType = expli;
     AppendChild(AttributeAccess);
     AppendChild(ExplicitType);
 }
 private static void ArgumentPart(SlimChainParser cp, out VariantType type, out string name, out TupleLiteral attr, out Element expli)
 {
     var ty = VariantType.Var;
     var n = string.Empty;
     TupleLiteral a = null;
     Element ex = null;
     cp.Transfer(e => a = e, AttributeList)
         .Opt.Any(
             icp => icp.Text("var").Self(() => ty = VariantType.Var),
             icp => icp.Text("let").Self(() => ty = VariantType.Let),
             icp => icp.Text("const").Self(() => ty = VariantType.Const)
         ).Lt()
         .Type(t => n = t.Text, TokenType.LetterStartString).Lt()
         .If(icp => icp.Type(TokenType.Pair).Lt())
         .Then(icp => icp.Transfer(e => ex = e, Prefix));
     type = ty;
     name = n;
     attr = a;
     expli = ex;
 }
        public void SetToProperty(UnityEngine.Object obj, string property)
        {
            if (obj == null) throw new System.ArgumentNullException("obj");
            var member = DynamicUtil.GetMember(obj, property, false);
            if(member == null)
            {
                _type = VariantType.Null;
            }
            else
            {
                var tp = DynamicUtil.GetReturnType(member);
                if (tp != null)
                    _type = VariantReference.GetVariantType(tp);
                else
                    _type = VariantType.Null;
            }

            _mode = RefMode.Property;
            _x = 0f;
            _y = 0f;
            _z = 0f;
            _w = 0d;

            _string = property;
            _unityObjectReference = obj;
        }
Example #39
0
 public void Initialize(string name, VariantType type, IReadOnlyList<AttributeSymbol> attr, TypeSymbol dt, Element def = null)
 {
     if(IsInitialize)
     {
         throw new InvalidOperationException();
     }
     IsInitialize = true;
     Name = name;
     VariantType = type;
     DefaultValue = def;
     AppendChild(DefaultValue);
     _Attribute = attr;
     _DataType = dt;
 }
Example #40
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="vt">Variant type</param>
		public SafeArrayMarshalType(VariantType vt)
			: this(vt, null) {
		}
 public static object Convert(object obj, VariantType tp)
 {
     switch (tp)
     {
         case VariantType.Object:
             return obj as UnityEngine.Object;
         case VariantType.Null:
             return null;
         case VariantType.String:
             return ConvertUtil.ToString(obj);
         case VariantType.Boolean:
             return ConvertUtil.ToBool(obj);
         case VariantType.Integer:
             return ConvertUtil.ToInt(obj);
         case VariantType.Float:
             return ConvertUtil.ToSingle(obj);
         case VariantType.Double:
             return ConvertUtil.ToDouble(obj);
         case VariantType.Vector2:
             if (obj is Vector2) return (Vector2)obj;
             return ConvertUtil.ToVector2(ConvertUtil.ToString(obj));
         case VariantType.Vector3:
             if (obj is Vector3) return (Vector3)obj;
             return ConvertUtil.ToVector3(ConvertUtil.ToString(obj));
         case VariantType.Quaternion:
             if (obj is Quaternion) return (Quaternion)obj;
             return ConvertUtil.ToQuaternion(ConvertUtil.ToString(obj));
         case VariantType.Color:
             return ConvertUtil.ToColor(obj);
         case VariantType.DateTime:
             return ConvertUtil.ToDate(obj);
         case VariantType.GameObject:
             return GameObjectUtil.GetGameObjectFromSource(obj);
         case VariantType.Component:
             return obj as Component;
     }
     return null;
 }
 void System.IDisposable.Dispose()
 {
     _mode = RefMode.Value;
     _type = VariantType.Null;
     _x = 0f;
     _y = 0f;
     _z = 0f;
     _w = 0.0;
     _string = null;
     _unityObjectReference = null;
 }
Example #43
0
        public static extern MsiError MsiSummaryInfoSetProperty(Int32 summaryInfo,
			uint id, VariantType type, int intValue, FILETIME fileTime, string value);
Example #44
0
        public static extern MsiError MsiSummaryInfoGetProperty(Int32 summaryInfo,
			uint id, out VariantType type, out int intValue, out FILETIME fileTime,
			StringBuilder value, ref int valueSize);
Example #45
0
		public Variant Cast(VariantType type)
		{
			switch (Type)
			{
				case VariantType.Int64:
					if (type == VariantType.String)
						return new Variant(ToString());

					if (type == VariantType.Double)
						return new Variant((double) IntValue);

					break;

				case VariantType.Double:
					if (type == VariantType.String)
						return new Variant(ToString());

					if (type == VariantType.Int64)
						return new Variant((Int64) DoubleValue);

					break;

				case VariantType.String:
					if (type == VariantType.Int64)
						return new Variant(Int64.Parse(StringValue, NumberStyles.Number, CultureInfo.InvariantCulture));

					if (type == VariantType.Double)
						return new Variant(Double.Parse(StringValue, NumberStyles.Number, CultureInfo.InvariantCulture));
					break;

				case VariantType.Array:
					if (type == VariantType.String)
						return new Variant(ToString());
					break;
			}

			throw new Exception(String.Format("Cannot cast type \"{0}\" to type \"{1}\"!", Type, type));
		}
Example #46
0
 public Variant()
 {
     varType = VariantType.vtUnknow;
 }
 public object GetValue(VariantType etp)
 {
     switch (etp)
     {
         case VariantType.Object:
             return this.ObjectValue;
         case VariantType.Null:
             return null;
         case VariantType.String:
             return this.StringValue;
         case VariantType.Boolean:
             return this.BoolValue;
         case VariantType.Integer:
             return this.IntValue;
         case VariantType.Float:
             return this.FloatValue;
         case VariantType.Double:
             return this.DoubleValue;
         case VariantType.Vector2:
             return this.Vector2Value;
         case VariantType.Vector3:
             return this.Vector3Value;
         case VariantType.Vector4:
             return this.Vector4Value;
         case VariantType.Quaternion:
             return this.QuaternionValue;
         case VariantType.Color:
             return this.ColorValue;
         case VariantType.DateTime:
             return this.DateValue;
         case VariantType.GameObject:
             return this.GameObjectValue;
         case VariantType.Component:
             return this.ComponentValue;
         case VariantType.LayerMask:
             return this.LayerMaskValue;
         case VariantType.Rect:
             return this.RectValue;
         default:
             return null;
     }
 }
Example #48
0
 public new void Initialize(string name, VariantType type, IReadOnlyList<AttributeSymbol> attr, TypeSymbol dt, Element def)
 {
     base.Initialize(name, type, attr, dt, def);
 }
 public void PrepareForValueTypeChange(VariantType type)
 {
     _variant._type = type;
     _variant._mode = RefMode.Value;
     _variant._x = 0f;
     _variant._y = 0f;
     _variant._z = 0f;
     _variant._w = 0d;
     _variant._string = string.Empty;
     switch(type)
     {
         case VariantType.Object:
             break;
         case VariantType.Null:
         case VariantType.String:
         case VariantType.Boolean:
         case VariantType.Integer:
         case VariantType.Float:
         case VariantType.Double:
         case VariantType.Vector2:
         case VariantType.Vector3:
         case VariantType.Quaternion:
         case VariantType.Color:
         case VariantType.DateTime:
             _variant._unityObjectReference = null;
             break;
         case VariantType.GameObject:
             _variant._unityObjectReference = GameObjectUtil.GetGameObjectFromSource(_variant._unityObjectReference);
             break;
         case VariantType.Component:
             _variant._unityObjectReference = _variant._unityObjectReference as Component;
             break;
     }
 }
Example #50
0
 public ConstPropVariant()
 {
     type = VariantType.None;
 }
 protected virtual object InputNum(VariantType vt)
 {
     this.ValidateReadable();
     this.SkipWhiteSpaceEOF();
     object obj2 = this.ReadInField(3);
     this.SkipTrailingWhiteSpace();
     return obj2;
 }
Example #52
0
 public void Dispose()
 {
     // If we are a ConstPropVariant, we must *not* call PropVariantClear.  That
     // would release the *caller's* copy of the data, which would probably make
     // him cranky.  If we are a PropVariant, the PropVariant.Dispose gets called
     // as well, which *does* do a PropVariantClear.
     type = VariantType.None;
     #if DEBUG
     longValue = 0;
     #endif
 }
 private VariantReference(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
 {
     var mode = (RefMode)info.GetByte("mode");
     switch(mode)
     {
         case RefMode.Value:
             _mode = RefMode.Value;
             _type = (VariantType)info.GetInt32("type");
             switch (_type)
             {
                 case VariantType.Object:
                 case VariantType.Null:
                     this.Value = null;
                     break;
                 case VariantType.String:
                     this.StringValue = info.GetString("value");
                     break;
                 case VariantType.Boolean:
                     this.BoolValue = info.GetBoolean("value");
                     break;
                 case VariantType.Integer:
                     this.IntValue = info.GetInt32("value");
                     break;
                 case VariantType.Float:
                     this.FloatValue = info.GetSingle("value");
                     break;
                 case VariantType.Double:
                     this.DoubleValue = info.GetDouble("value");
                     break;
                 case VariantType.Vector2:
                 case VariantType.Vector3:
                 case VariantType.Quaternion:
                 case VariantType.Color:
                     var arr = StringUtil.SplitFixedLength(info.GetString("value"), ",", 4);
                     _x = ConvertUtil.ToSingle(arr[0]);
                     _y = ConvertUtil.ToSingle(arr[1]);
                     _z = ConvertUtil.ToSingle(arr[2]);
                     _w = ConvertUtil.ToDouble(arr[3]);
                     break;
                 case VariantType.DateTime:
                     this.DateValue = info.GetDateTime("value");
                     break;
                 case VariantType.GameObject:
                 case VariantType.Component:
                     this.Value = null;
                     break;
             }
             break;
         case RefMode.Property:
             this.Value = null; //just set to null value
             break;
     }
 }
Example #54
0
 protected ArgumentSymbol(TextPosition tp, VariantType type, Element def)
     : base(tp, type, def)
 {
 }
Example #55
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="vt">Variant type</param>
		/// <param name="userDefinedSubType">User-defined sub type</param>
		public SafeArrayMarshalType(VariantType vt, ITypeDefOrRef userDefinedSubType)
			: base(NativeType.SafeArray) {
			this.vt = vt;
			this.userDefinedSubType = userDefinedSubType;
		}
Example #56
0
		bool GetFlagValue(VariantType flag) {
			return (SafeArrayMarshalType_VT & flag) != 0;
		}
		public SafeArrayMarshalInfo ()
			: base (NativeType.SafeArray)
		{
			element_type = VariantType.None;
		}
 protected ConstPropVariant(VariantType v)
 {
     type = v;
 }
Example #59
0
		void SetFlagValue(VariantType flag, bool value) {
			if (value)
				SafeArrayMarshalType_VT |= flag;
			else
				SafeArrayMarshalType_VT &= ~flag;
		}
Example #60
0
 private void AppendEmbededAttribute(List<AttributeSymbol> list, FieldInfo field, out VariantType type)
 {
     type = VariantType.Var;
     if (field.IsFamily) list.Add(Root.Protected);
     if (field.IsFamilyOrAssembly) list.Add(Root.Protected);
     if (field.IsInitOnly) type = VariantType.Let;
     if (field.IsLiteral) type = VariantType.Const;
     if (field.IsPublic) list.Add(Root.Public);
     if (field.IsStatic) list.Add(Root.Static);
 }