Inheritance: System.Attribute
Exemplo n.º 1
0
        public NearCondition(StringValue operand, IField field = null, uint? boost = null, uint? distance = null)
            : base(operand, field, boost)
        {
            Distance = distance;

            if (Distance.HasValue) AddOption("distance", Distance.ToString());
        }
Exemplo n.º 2
0
        public SetValue Function(StringValue name, ArgumentsValue args)
        {
            var set = new SetValue(name.Value, null, false);

            int iArgs = 1; //First is "name"
            foreach (var arg in args)
            {
                iArgs++;
                if (arg is MatrixValue)
                {
                    set.AddElements((arg as MatrixValue).ToArray());
                }
                else if (arg is StringValue)
                {
                    set.Set.Add((arg as StringValue).Value);
                }
                else if (arg is NumericValue)
                {
                    set.Set.Add(arg as NumericValue);
                }
                else
                    throw new YAMPArgumentInvalidException("Element is not ScalarValue, StringValue or MatrixValue", iArgs);
            }
            return set;
        }
Exemplo n.º 3
0
 public MatrixValue Function(StringValue str)
 {
     var m = new MatrixValue();
     m[1, 1] = new ScalarValue(1);
     m[1, 2] = new ScalarValue(str.Value.Length);
     return m;
 }
Exemplo n.º 4
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     if (txtbxExtField.Text.Trim().Length != 0)
     {
         var str = new StringValue(txtbxExtField.Text);
         extensions.Add(str);
         dgrExtensions.Items.Refresh();
     }
 }
        public void AddParagraphToWordBullet(WordprocessingDocument doc, StringValue bulletNumChar)
        {
            MainDocumentPart mainPart = doc.MainDocumentPart;
            WordDoc.Body body = mainPart.Document.Body;
            WordDoc.Paragraph para = body.AppendChild(new WordDoc.Paragraph());

            WordDoc.ParagraphProperties pp = para.AppendChild(new WordDoc.ParagraphProperties(
                new WordDoc.NumberingProperties(
                new WordDoc.NumberingLevelReference() { Val = 0 },
                new WordDoc.NumberingId() { Val = 1 })));
        }
Exemplo n.º 6
0
        public MatrixValue Function(StringValue f, ScalarValue n, ScalarValue dt, ArgumentsValue args)
        {
            var function = GetSensorFunction(f.Value);

            if (function == null)
            {
                throw new YAMPRuntimeException("The given function {0} could not be found.", f.Value);
            }

            return Function(new FunctionValue(function), n, dt, args);
        }
Exemplo n.º 7
0
        public ScalarValue Function(StringValue option)
        {
            var callback = default(Func<Gps, ScalarValue>);

            if (NamedProperties.TryGetValue(option.Value, out callback))
            {
                return callback(_sensor);
            }

            return new ScalarValue();
        }
Exemplo n.º 8
0
        public void TestConcat()
        {
            // Arrange
            var erik = new StringValue("Erik");
            var verhoofstad = new StringValue("Verhoofstad");

            // Act
            var erikVerhoofstad = erik.Plus(verhoofstad) as StringValue;

            // Assert
            Assert.AreEqual<string>("ErikVerhoofstad", erikVerhoofstad.Val);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNewValue.Text))
            {
                //TODO: How smart is this list constraint? Is a list of
                //number strings treated as a list of numbers?
                DataValue val = new StringValue(txtNewValue.Text);

                txtNewValue.Text = string.Empty;
                lstValues.Items.Add(val);
            }
        }
Exemplo n.º 10
0
        public void TestIsEqualTo()
        {
            // Arrange
            var erikA = new StringValue("Erik");
            var erikB = new StringValue("Erik");

            // Act
            var result = erikA.IsEqualTo(erikB) as BooleanValue;

            // Assert
            Assert.IsTrue(result.Val);
        }
Exemplo n.º 11
0
        public ScalarValue Function(StringValue p)
        {
            var conv = new StringToEnumConverter(typeof(AudioProperty));
            var property = (AudioProperty)conv.Convert(p);
            var callback = default(Func<Microphone, ScalarValue>);

            if (NamedProperties.TryGetValue(property, out callback))
            {
                return callback(_sensor);
            }

            return new ScalarValue();
        }
Exemplo n.º 12
0
        public ScalarValue Function(StringValue p)
        {
            var conv = new StringToEnumConverter(typeof(VideoProperty));
            var property = (VideoProperty)conv.Convert(p);
            var deviceReader = default(VideoDeviceReader);

            if (NamedProperties.TryGetValue(property, out deviceReader))
            {
                return deviceReader.GetValue(_sensor);
            }

            return new ScalarValue();
        }
        public void TestExistingTemplateValueLookup()
        {
            IDictionary dictionary = new TemplateDictionary();
            Group template = new MessageTemplate(
                "Position",
                new Field[]
                    {
                        new Scalar("exchange", FastType.String, Operator.Copy, ScalarValue.Undefined, false)
                    });
            ScalarValue value = new StringValue("NYSE");
            dictionary.Store(template, new QName("exchange"), FastConstants.AnyType, value);

            Assert.AreEqual(ScalarValue.Undefined, dictionary.Lookup(template, new QName("bid"), FastConstants.AnyType));
        }
Exemplo n.º 14
0
        public static StringValue ApplyDifference(StringValue baseValue, TwinValue diffValue)
        {
            int subtraction = ((IntegerValue) diffValue.first).value_Renamed;
            string base_Renamed = baseValue.value_Renamed;
            string diff = ((StringValue) diffValue.second).value_Renamed;

            if (subtraction < 0)
            {
                subtraction = ((- 1) * subtraction) - 1;

                return new StringValue(diff + base_Renamed.Substring(subtraction, (base_Renamed.Length) - (subtraction)));
            }

            return new StringValue(base_Renamed.Substring(0, (base_Renamed.Length - subtraction) - (0)) + diff);
        }
            public ReportRow(Worksheet worksheet, int rowIndex, FomsReportRowType rowType)
                : base(worksheet)
            {
                RowIndex = rowIndex;
                RowType = rowType;

                var colIndex = 1;
                Name = new StringValue(worksheet, rowIndex, colIndex++);
                StacFullCount = new DoubleValue(worksheet, rowIndex, colIndex++);
                StacDayCount = new DoubleValue(worksheet, rowIndex, colIndex++);
                EmergencyCount = new DoubleValue(worksheet, rowIndex, colIndex++);
                TreatmentCount = new DoubleValue(worksheet, rowIndex, colIndex++);
                VisitCount = new DoubleValue(worksheet, rowIndex, colIndex++);
                AmbulanceCount = new DoubleValue(worksheet, rowIndex, colIndex++);
            }
        public void TestLookupMultipleValuesForTemplate()
        {
            IDictionary dictionary = new TemplateDictionary();
            Group template = new MessageTemplate(
                "Position",
                new Field[]
                    {
                        new Scalar("exchange", FastType.String, Operator.Copy, ScalarValue.Undefined, false)
                    });
            ScalarValue value = new StringValue("NYSE");
            ScalarValue marketValue = new DecimalValue(100000.00);
            dictionary.Store(template, new QName("exchange"), FastConstants.AnyType, value);
            dictionary.Store(template, new QName("marketValue"), FastConstants.AnyType, marketValue);

            Assert.AreNotEqual(ScalarValue.Undefined, value);
            Assert.AreEqual(value, dictionary.Lookup(template, new QName("exchange"), FastConstants.AnyType));
            Assert.AreEqual(marketValue, dictionary.Lookup(template, new QName("marketValue"), FastConstants.AnyType));
        }
Exemplo n.º 17
0
        public void Function(StringValue path)
        {
            var p = path.Value;

            if (!Path.IsPathRooted(path.Value))
            {
                p = Path.Combine(Environment.CurrentDirectory, path.Value);
            }

            if (!Directory.Exists(path.Value))
            {
                RaiseNotification(NotificationType.Failure, "The directory " + p + " could not be found.");
            }
            else
            {
                Environment.CurrentDirectory = path.Value;
            }
        }
Exemplo n.º 18
0
	// ================================================================================================================

	public static void Show(StringValue stringVal, EditorWindow ed)
	{
		if (stringVal == null)
		{
			Debug.LogError("Invalid value");
			return;
		}

		// make sure DB is loaded
		if (!UniRPGEditorGlobal.LoadDatabase()) return;

		// create window
		GlobalVarSelectWiz window = EditorWindow.GetWindow<GlobalVarSelectWiz>(true, "Select Variable", true);
		window.inited = false;
		window.ed = ed;
		window.stringVal = stringVal;

		// show window
		window.ShowUtility();
	}
Exemplo n.º 19
0
        public void Function(StringValue fileName, ArgumentsValue args)
        {
            var workspace = new Dictionary<String, Value>();

            foreach (var arg in args.Values)
            {
                if (arg is StringValue)
                {
                    var name = (arg as StringValue).Value;

                    if (Context.Variables.ContainsKey(name))
                    {
                        workspace.Add(name, Context.Variables[name]);
                    }
                }
            }

            Save(fileName.Value, workspace);
            Notify(workspace.Count);
        }
Exemplo n.º 20
0
        public StringValue Function(StringValue filter)
        {
            var sb = new StringBuilder();
            var dir = new DirectoryInfo(Environment.CurrentDirectory);

            sb.AppendFormat("{0,-32} {1,-10}   {2}", "Name", "Attributes", "Last changed").AppendLine();
            sb.AppendLine("------------------------------------------------------------");

            foreach (var subdir in dir.GetDirectories(filter.Value))
            {
                sb.AppendFormat("{0,-32}  {1,-8}  {2} {3}", Limit(subdir.Name), PrintAttributes(subdir.Attributes),
                    subdir.LastWriteTime.ToShortDateString(), subdir.LastWriteTime.ToShortTimeString());
                sb.AppendLine();
            }

            foreach (var file in dir.GetFiles(filter.Value))
            {
                sb.AppendFormat("{0,-32}  {1,-8}  {2} {3}", Limit(file.Name), PrintAttributes(file.Attributes),
                    file.LastWriteTime.ToShortDateString(), file.LastWriteTime.ToShortTimeString());
                sb.AppendLine();
            }

            return new StringValue(sb.ToString());
        }
Exemplo n.º 21
0
 public static Font CreateCustomFont(
     Fonts fonts,
     DoubleValue fontSize,
     UInt32Value color,
     StringValue fontName,
     bool isBold = false,
     bool isItalic = false,
     bool isUnderline = false)
 {
     return CreateFont(fonts, fontSize, color, fontName, FamilyNumberingCustom, UsedCharSet, isBold, isItalic, isUnderline);
 }
Exemplo n.º 22
0
 /**
  * Finds the function
  */
 public override AbstractFunction findFunction(StringValue name)
 {
     return(_program.findFunction(name));
 }
Exemplo n.º 23
0
        /// <summary>
        /// Given a cell name, parses the specified cell to get the row index.
        /// </summary>
        /// <param name="cellReference">Address of the cell (ie. B2).</param>
        /// <returns>Row index (ie. 2).</returns>
        private static uint getRowIndex(StringValue cellReference)
        {
            // Use a regular expression to match the row index portion the cell name.
            const string pattern = @"\d+";
            var match = Regex.Match(cellReference, pattern);
            var rowIndex = uint.Parse(match.Value);

            return rowIndex;
        }
        public bool unlink(Env env, StringValue path)
        {
            env.warning(L.l("unlink not supported by protocol"));

            return(false);
        }
Exemplo n.º 25
0
 /// <summary cref="IValueVisitor.Visit(StringValue)"/>
 public void Visit(StringValue value) =>
 CodeGenerator.GenerateCode(value);
Exemplo n.º 26
0
        /**
         * Creates the text statement with its string.
         */
        public TextStatement(Location location, StringValue value)
        {
            super(location);

            _value = value;
        }
        public bool rmdir(Env env, StringValue path, LongValue options)
        {
            env.warning(L.l("rmdir not supported by protocol"));

            return(false);
        }
Exemplo n.º 28
0
        private ListValue GetModulesInGroup(StringValue groupName)
        {
            var    matchGroup = KSPActionGroup.None;
            string upperName  = groupName.ToUpper();

            // TODO: later refactor:  put this in a Dictionary lookup instead, and then share it
            // by both this code and the code in ActionGroup.cs:
            if (upperName == "SAS")
            {
                matchGroup = KSPActionGroup.SAS;
            }
            if (upperName == "GEAR")
            {
                matchGroup = KSPActionGroup.Gear;
            }
            if (upperName == "LIGHTS")
            {
                matchGroup = KSPActionGroup.Light;
            }
            if (upperName == "BRAKES")
            {
                matchGroup = KSPActionGroup.Brakes;
            }
            if (upperName == "RCS")
            {
                matchGroup = KSPActionGroup.RCS;
            }
            if (upperName == "ABORT")
            {
                matchGroup = KSPActionGroup.Abort;
            }
            if (upperName == "AG1")
            {
                matchGroup = KSPActionGroup.Custom01;
            }
            if (upperName == "AG2")
            {
                matchGroup = KSPActionGroup.Custom02;
            }
            if (upperName == "AG3")
            {
                matchGroup = KSPActionGroup.Custom03;
            }
            if (upperName == "AG4")
            {
                matchGroup = KSPActionGroup.Custom04;
            }
            if (upperName == "AG5")
            {
                matchGroup = KSPActionGroup.Custom05;
            }
            if (upperName == "AG6")
            {
                matchGroup = KSPActionGroup.Custom06;
            }
            if (upperName == "AG7")
            {
                matchGroup = KSPActionGroup.Custom07;
            }
            if (upperName == "AG8")
            {
                matchGroup = KSPActionGroup.Custom08;
            }
            if (upperName == "AG9")
            {
                matchGroup = KSPActionGroup.Custom09;
            }
            if (upperName == "AG10")
            {
                matchGroup = KSPActionGroup.Custom10;
            }

            ListValue kScriptParts = new ListValue();

            // This is almost identical to the logic in GetPartsInGroup and it might be a nice idea
            // later to merge them somehow:
            //
            if (matchGroup == KSPActionGroup.None)
            {
                return(kScriptParts);
            }

            foreach (global::Part p in Vessel.parts)
            {
                foreach (PartModule pm in p.Modules)
                {
                    if (pm.Actions.Any(a => a.actionGroup.Equals(matchGroup)))
                    {
                        kScriptParts.Add(PartModuleFieldsFactory.Construct(pm, Shared));
                    }
                }
            }

            return(kScriptParts);
        }
Exemplo n.º 29
0
 private void RetypeVessel(StringValue value)
 {
     Vessel.vesselType = value.ToString().ToEnum <VesselType>();
 }
Exemplo n.º 30
0
 private ListValue GetPartsTagged(StringValue tagName)
 {
     return(PartValueFactory.Construct(GetRawPartsTagged(tagName), Shared));
 }
Exemplo n.º 31
0
        private ListValue GetPartsInGroup(StringValue groupName)
        {
            var    matchGroup = KSPActionGroup.None;
            string upperName  = groupName.ToUpper();

            // TODO: later refactor:  put this in a Dictionary lookup instead, and then share it
            // by both this code and the code in ActionGroup.cs:
            if (upperName == "SAS")
            {
                matchGroup = KSPActionGroup.SAS;
            }
            if (upperName == "GEAR")
            {
                matchGroup = KSPActionGroup.Gear;
            }
            if (upperName == "LIGHTS")
            {
                matchGroup = KSPActionGroup.Light;
            }
            if (upperName == "BRAKES")
            {
                matchGroup = KSPActionGroup.Brakes;
            }
            if (upperName == "RCS")
            {
                matchGroup = KSPActionGroup.RCS;
            }
            if (upperName == "ABORT")
            {
                matchGroup = KSPActionGroup.Abort;
            }
            if (upperName == "AG1")
            {
                matchGroup = KSPActionGroup.Custom01;
            }
            if (upperName == "AG2")
            {
                matchGroup = KSPActionGroup.Custom02;
            }
            if (upperName == "AG3")
            {
                matchGroup = KSPActionGroup.Custom03;
            }
            if (upperName == "AG4")
            {
                matchGroup = KSPActionGroup.Custom04;
            }
            if (upperName == "AG5")
            {
                matchGroup = KSPActionGroup.Custom05;
            }
            if (upperName == "AG6")
            {
                matchGroup = KSPActionGroup.Custom06;
            }
            if (upperName == "AG7")
            {
                matchGroup = KSPActionGroup.Custom07;
            }
            if (upperName == "AG8")
            {
                matchGroup = KSPActionGroup.Custom08;
            }
            if (upperName == "AG9")
            {
                matchGroup = KSPActionGroup.Custom09;
            }
            if (upperName == "AG10")
            {
                matchGroup = KSPActionGroup.Custom10;
            }

            ListValue kScriptParts = new ListValue();

            if (matchGroup == KSPActionGroup.None)
            {
                return(kScriptParts);
            }

            foreach (global::Part p in Vessel.parts)
            {
                // See if any of the parts' actions are this action group:
                bool hasPartAction = p.Actions.Any(a => a.actionGroup.Equals(matchGroup));
                if (hasPartAction)
                {
                    kScriptParts.Add(PartValueFactory.Construct(p, Shared));
                    continue;
                }

                var  modules         = p.Modules.Cast <PartModule>();
                bool hasModuleAction = modules.Any(pm => pm.Actions.Any(a => a.actionGroup.Equals(matchGroup)));
                if (hasModuleAction)
                {
                    kScriptParts.Add(PartValueFactory.Construct(p, Shared));
                }
            }
            return(kScriptParts);
        }
Exemplo n.º 32
0
 private ListValue GetPartsTitled(StringValue partTitle)
 {
     return(PartValueFactory.Construct(GetRawPartsTitled(partTitle), Shared));
 }
Exemplo n.º 33
0
        //var numberCell = new Cell {
        //	DataType = CellValues.Number,
        //	CellReference = header + index,
        //	CellValue = new CellValue(text),
        //	StyleIndex = 3
        //};
        public void Execute()
        {
            List <Person> personen   = GetData();
            String        pathToTemp = @"..\..\testFolder";

            if (!Directory.Exists(pathToTemp))
            {
                Directory.CreateDirectory(pathToTemp);
            }

            String tempFile = pathToTemp + "\\" + DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond + ".xlsx";

            using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Create(tempFile, SpreadsheetDocumentType.Workbook)) {
                // create the workbook

                var dateFormat = new NumberingFormat()
                {
                    NumberFormatId = (UInt32Value)0,
                    FormatCode     = StringValue.FromString("dd.MM.yyyy")
                };
                WorkbookPart part = spreadSheet.AddWorkbookPart();
                part.Workbook = new Workbook();
                part.AddNewPart <WorksheetPart>();
                part.WorksheetParts.First().Worksheet = new Worksheet();
                WorkbookStylesPart sp = spreadSheet.WorkbookPart.AddNewPart <WorkbookStylesPart>();
                sp.Stylesheet = new Stylesheet();
                sp.Stylesheet.NumberingFormats = new NumberingFormats();
                sp.Stylesheet.NumberingFormats.Append(dateFormat);

                CellFormat cellFormat = new CellFormat();
                cellFormat.NumberFormatId    = dateFormat.NumberFormatId;
                cellFormat.ApplyNumberFormat = BooleanValue.FromBoolean(true);


                sp.Stylesheet.CellFormats = new CellFormats();
                sp.Stylesheet.CellFormats.AppendChild <CellFormat>(cellFormat);

                sp.Stylesheet.CellFormats.Count = UInt32Value.FromUInt32((uint)sp.Stylesheet.CellFormats.ChildElements.Count);


                sp.Stylesheet.Save();
                Sheets sheets = spreadSheet.WorkbookPart.Workbook.AppendChild <Sheets>(new Sheets());


                // create sheet data

                foreach (Person p in personen)
                {
                    WorksheetPart tabPart    = part.AddNewPart <WorksheetPart>();
                    Worksheet     workSheet1 = new Worksheet();
                    SheetData     sheetData1 = new SheetData();

                    Sheet sheet1 = new Sheet()
                    {
                        Id      = spreadSheet.WorkbookPart.GetIdOfPart(tabPart),
                        SheetId = 1,
                        Name    = p.Name
                    };

                    sheets.Append(sheet1);

                    Row r = new Row();

                    r.AppendChild(new Cell()
                    {
                        CellValue = new CellValue(p.Name), DataType = CellValues.String
                    });
                    r.AppendChild(new Cell()
                    {
                        CellValue = new CellValue(p.BirthDay.ToOADate().ToString()), StyleIndex = 0
                    });
                    r.AppendChild(new Cell()
                    {
                        CellValue = new CellValue(p.HeightInCm.ToString(CultureInfo.InvariantCulture)), DataType = CellValues.Number
                    });
                    r.AppendChild(new Cell()
                    {
                        CellValue = new CellValue(p.Weight.ToString(CultureInfo.InvariantCulture)), DataType = CellValues.Number
                    });


                    sheetData1.AppendChild(r);


                    workSheet1.AppendChild(sheetData1);
                    tabPart.Worksheet = workSheet1;
                }
                part.Workbook.Save();
            }

            Process.Start(@tempFile);
            Environment.Exit(0);
        }
Exemplo n.º 34
0
        public Stylesheet CreateStylesheet()
        {
            Stylesheet ss = new Stylesheet();

            Fonts fts = new Fonts();

            Font ft = new Font()
            {
                FontName = new FontName()
                {
                    Val = StringValue.FromString("Arial")
                },
                FontSize = new FontSize()
                {
                    Val = DoubleValue.FromDouble(8)
                }
            };

            fts.Append(ft);

            ft = new Font()
            {
                FontName = new FontName()
                {
                    Val = StringValue.FromString("Arial")
                },
                FontSize = new FontSize()
                {
                    Val = DoubleValue.FromDouble(18)
                }
            };
            fts.Append(ft);

            ft = new Font()
            {
                FontName = new FontName()
                {
                    Val = StringValue.FromString("Arial")
                },
                FontSize = new FontSize()
                {
                    Val = DoubleValue.FromDouble(9)
                },
                Bold = new Bold()
            };//new Bold() { Val = new BooleanValue(true) }
            fts.Append(ft);

            ft = new Font()
            {
                FontName = new FontName()
                {
                    Val = StringValue.FromString("Arial")
                },
                FontSize = new FontSize()
                {
                    Val = DoubleValue.FromDouble(14)
                }
            };
            fts.Append(ft);

            fts.Count = UInt32Value.FromUInt32((uint)fts.ChildElements.Count);

            Fills fills = new Fills();
            Fill  fill  = new Fill()
            {
                PatternFill = new PatternFill()
                {
                    PatternType = PatternValues.None
                }
            };

            fills.Append(fill);

            fill = new Fill()
            {
                PatternFill = new PatternFill()
                {
                    PatternType = PatternValues.Gray125
                }
            };
            fills.Append(fill);

            fill = new Fill()
            {
                PatternFill = new PatternFill()
                {
                    PatternType     = PatternValues.Solid,
                    ForegroundColor = new ForegroundColor()
                    {
                        Rgb = HexBinaryValue.FromString("00d3d3d3")
                    },
                    BackgroundColor = new BackgroundColor()
                    {
                        Rgb = HexBinaryValue.FromString("00d3d3d3")
                    }
                }
            };
            fills.Append(fill);

            fills.Count = UInt32Value.FromUInt32((uint)fills.ChildElements.Count);

            Borders borders = new Borders();
            Border  border  = new Border()
            {
                LeftBorder     = new LeftBorder(),
                RightBorder    = new RightBorder(),
                TopBorder      = new TopBorder(),
                BottomBorder   = new BottomBorder(),
                DiagonalBorder = new DiagonalBorder()
            };

            borders.Append(border);

            border = new Border()
            {
                LeftBorder = new LeftBorder()
                {
                    Style = BorderStyleValues.Thin
                },
                RightBorder = new RightBorder()
                {
                    Style = BorderStyleValues.Thin
                },
                TopBorder = new TopBorder()
                {
                    Style = BorderStyleValues.Thin
                },
                BottomBorder = new BottomBorder()
                {
                    Style = BorderStyleValues.Thin
                },
                DiagonalBorder = new DiagonalBorder()
            };
            borders.Append(border);

            border = new Border()
            {
                LeftBorder = new LeftBorder()
                {
                    Style = BorderStyleValues.Thick
                },
                RightBorder = new RightBorder()
                {
                    Style = BorderStyleValues.Thick
                },
                TopBorder = new TopBorder()
                {
                    Style = BorderStyleValues.Thick
                },
                BottomBorder = new BottomBorder()
                {
                    Style = BorderStyleValues.Thick
                },
                DiagonalBorder = new DiagonalBorder()
            };
            borders.Append(border);

            border = new Border()
            {
                LeftBorder  = new LeftBorder(),
                RightBorder = new RightBorder(),
                TopBorder   = new TopBorder()
                {
                    Style = BorderStyleValues.Double
                },
                BottomBorder   = new BottomBorder(),
                DiagonalBorder = new DiagonalBorder()
            };
            borders.Append(border);

            borders.Count = UInt32Value.FromUInt32((uint)borders.ChildElements.Count);

            CellStyleFormats csfs = new CellStyleFormats();
            CellFormat       cf   = new CellFormat()
            {
                NumberFormatId = 0, FontId = 0, FillId = 0, BorderId = 0
            };

            csfs.Append(cf);
            csfs.Count = UInt32Value.FromUInt32((uint)csfs.ChildElements.Count);

            uint             iExcelIndex = 164;
            NumberingFormats nfs         = new NumberingFormats();
            CellFormats      cfs         = new CellFormats();

            cf = new CellFormat()
            {
                NumberFormatId = 0, FontId = 0, FillId = 0, BorderId = 0, FormatId = 0
            };
            cfs.Append(cf);

            NumberingFormat nfDateTime = new NumberingFormat()
            {
                NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++),
                FormatCode     = StringValue.FromString("dd/mm/yyyy hh:mm:ss")
            };

            nfs.Append(nfDateTime);

            NumberingFormat nf4decimal = new NumberingFormat()
            {
                NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++),
                FormatCode     = StringValue.FromString("#,##0.00")
            };

            nfs.Append(nf4decimal);

            // #,##0.00 is also Excel style index 4
            NumberingFormat nf2decimal = new NumberingFormat()
            {
                NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++),
                FormatCode     = StringValue.FromString("#,##0.00")
            };

            nfs.Append(nf2decimal);

            // @ is also Excel style index 49
            NumberingFormat nfForcedText = new NumberingFormat()
            {
                NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++),
                FormatCode     = StringValue.FromString("@")
            };

            nfs.Append(nfForcedText);

            // index 1
            cf = new CellFormat()
            {
                NumberFormatId = nfDateTime.NumberFormatId, FontId = 0, FillId = 0, BorderId = 0, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 2
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 0, FillId = 0, BorderId = 0, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 3
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 0, FillId = 0, BorderId = 1, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 4
            cf = new CellFormat()
            {
                NumberFormatId = nfForcedText.NumberFormatId, FontId = 0, FillId = 0, BorderId = 0, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 5 Header text
            cf = new CellFormat()
            {
                NumberFormatId = nfForcedText.NumberFormatId, FontId = 1, FillId = 0, BorderId = 0, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 6 column text
            cf = new CellFormat()
            {
                NumberFormatId = nfForcedText.NumberFormatId, FontId = 0, FillId = 0, BorderId = 1, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cf.Alignment = new Alignment()
            {
                Vertical = new EnumValue <VerticalAlignmentValues>(VerticalAlignmentValues.Center)
            };
            cfs.Append(cf);

            // index 7 coloured 2 decimal text
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 0, FillId = 2, BorderId = 1, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 8 coloured column text
            cf = new CellFormat()
            {
                NumberFormatId = nfForcedText.NumberFormatId, FontId = 0, FillId = 2, BorderId = 1, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 9
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 2, FillId = 0, BorderId = 1, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 10
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 2, FillId = 2, BorderId = 1, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cf.Alignment = new Alignment()
            {
                Vertical = VerticalAlignmentValues.Center, Horizontal = HorizontalAlignmentValues.Center
            };
            cfs.Append(cf);

            // index 11
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 2, FillId = 0, BorderId = 3, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 12
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 2, FillId = 0, BorderId = 0, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            // index 13
            cf = new CellFormat()
            {
                NumberFormatId = nf2decimal.NumberFormatId, FontId = 3, FillId = 0, BorderId = 0, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true)
            };
            cfs.Append(cf);

            nfs.Count = UInt32Value.FromUInt32((uint)nfs.ChildElements.Count);
            cfs.Count = UInt32Value.FromUInt32((uint)cfs.ChildElements.Count);

            ss.Append(nfs);
            ss.Append(fts);
            ss.Append(fills);
            ss.Append(borders);
            ss.Append(csfs);
            ss.Append(cfs);

            var css = new CellStyles();

            DocumentFormat.OpenXml.Spreadsheet.CellStyle cs = new DocumentFormat.OpenXml.Spreadsheet.CellStyle()
            {
                Name = StringValue.FromString("Normal"), FormatId = 0, BuiltinId = 0
            };
            css.Append(cs);
            css.Count = UInt32Value.FromUInt32((uint)css.ChildElements.Count);
            ss.Append(css);

            var dfs = new DifferentialFormats {
                Count = 0
            };

            ss.Append(dfs);

            TableStyles tss = new TableStyles()
            {
                Count = 0, DefaultTableStyle = StringValue.FromString("TableStyleMedium9"), DefaultPivotStyle = StringValue.FromString("PivotStyleLight16")
            };

            ss.Append(tss);

            return(ss);
        }
Exemplo n.º 35
0
 /// <inheritdoc />
 public override void VisitStringValue(StringValue value)
 {
     stringVisitor.SetLeftOperand(value);
     visitor = stringVisitor;
 }
Exemplo n.º 36
0
 internal virtual Value IsNotEqualToString(StringValue value)
 {
     throw new InvalidOperationException(CreateMessage(Operation.NotEqualTo, value, this));
 }
Exemplo n.º 37
0
        private static void ProcessTag([NotNull] SequentialReader reader, [NotNull] Directory directory, int directoryType, int tagType, int tagByteCount)
        {
            var tagIdentifier = tagType | (directoryType << 8);

            // Some images have been seen that specify a zero byte tag, which cannot be of much use.
            // We elect here to completely ignore the tag. The IPTC specification doesn't mention
            // anything about the interpretation of this situation.
            // https://raw.githubusercontent.com/wiki/drewnoakes/metadata-extractor/docs/IPTC-IIMV4.2.pdf
            if (tagByteCount == 0)
            {
                directory.Set(tagIdentifier, string.Empty);
                return;
            }

            switch (tagIdentifier)
            {
            case IptcDirectory.TagCodedCharacterSet:
            {
                var bytes   = reader.GetBytes(tagByteCount);
                var charset = Iso2022Converter.ConvertEscapeSequenceToEncodingName(bytes);
                if (charset == null)
                {
                    // Unable to determine the charset, so fall through and treat tag as a regular string
                    charset = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
                }
                directory.Set(tagIdentifier, charset);
                return;
            }

            case IptcDirectory.TagEnvelopeRecordVersion:
            case IptcDirectory.TagApplicationRecordVersion:
            case IptcDirectory.TagFileVersion:
            case IptcDirectory.TagArmVersion:
            case IptcDirectory.TagProgramVersion:
            {
                // short
                if (tagByteCount >= 2)
                {
                    var shortValue = reader.GetUInt16();
                    reader.Skip(tagByteCount - 2);
                    directory.Set(tagIdentifier, shortValue);
                    return;
                }
                break;
            }

            case IptcDirectory.TagUrgency:
            {
                // byte
                directory.Set(tagIdentifier, reader.GetByte());
                reader.Skip(tagByteCount - 1);
                return;
            }
            }

            // If we haven't returned yet, treat it as a string
            // NOTE that there's a chance we've already loaded the value as a string above, but failed to parse the value
            var      encodingName = directory.GetString(IptcDirectory.TagCodedCharacterSet);
            Encoding encoding     = null;

            if (encodingName != null)
            {
                try
                {
                    encoding = Encoding.GetEncoding(encodingName);
                }
                catch (ArgumentException)
                { }
            }

            StringValue str;

            if (encoding != null)
            {
                str = reader.GetStringValue(tagByteCount, encoding);
            }
            else
            {
                var bytes = reader.GetBytes(tagByteCount);
                encoding = Iso2022Converter.GuessEncoding(bytes);
                str      = new StringValue(bytes, encoding);
            }

            if (directory.ContainsTag(tagIdentifier))
            {
                // this fancy string[] business avoids using an ArrayList for performance reasons
                var oldStrings = directory.GetStringValueArray(tagIdentifier);

                StringValue[] newStrings;
                if (oldStrings == null)
                {
                    // TODO hitting this block means any prior value(s) are discarded
                    newStrings = new StringValue[1];
                }
                else
                {
                    newStrings = new StringValue[oldStrings.Length + 1];
                    Array.Copy(oldStrings, 0, newStrings, 0, oldStrings.Length);
                }
                newStrings[newStrings.Length - 1] = str;
                directory.Set(tagIdentifier, newStrings);
            }
            else
            {
                directory.Set(tagIdentifier, str);
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// First 5 candidates will get 500 * 2 votes, next 14 candidates will get 250 * 2 votes.
        /// Votes are got from 2 different voters.
        /// </summary>
        /// <returns></returns>
        public async Task <List <ECKeyPair> > ElectionContract_Vote_Test()
        {
            const int  votersCount = 2;
            const long amount      = 500;
            const int  lockTime    = 100 * 60 * 60 * 24;

            var candidatesKeyPairs = await ElectionContract_AnnounceElection_Test();

            var candidateKeyPair = candidatesKeyPairs[0];

            var votersKeyPairs      = VoterKeyPairs.Take(votersCount).ToList();
            var voterKeyPair        = votersKeyPairs[0];
            var balanceBeforeVoting = await GetNativeTokenBalance(voterKeyPair.PublicKey);

            balanceBeforeVoting.ShouldBeGreaterThan(0);

            await VoteToCandidates(
                votersKeyPairs.Take(EconomicContractsTestConstants.InitialCoreDataCenterCount).ToList(),
                candidatesKeyPairs.Select(p => p.PublicKey.ToHex()).ToList(), lockTime, amount);

            await VoteToCandidates(
                votersKeyPairs.Skip(EconomicContractsTestConstants.InitialCoreDataCenterCount)
                .Take(candidatesKeyPairs.Count - EconomicContractsTestConstants.InitialCoreDataCenterCount)
                .ToList(),
                candidatesKeyPairs.Select(p => p.PublicKey.ToHex()).ToList(), lockTime, amount / 2);

            var actualVotedAmount =
                amount * EconomicContractsTestConstants.InitialCoreDataCenterCount + amount *
                (candidatesKeyPairs.Count - EconomicContractsTestConstants.InitialCoreDataCenterCount);

            // Check ELF token balance.
            {
                var balance = await GetNativeTokenBalance(voterKeyPair.PublicKey);

                balance.ShouldBe(balanceBeforeVoting - actualVotedAmount * 10000_0000);
            }

            // Check VOTE token balance.
            {
                var balance = await GetVoteTokenBalance(voterKeyPair.PublicKey);

                balance.ShouldBe(actualVotedAmount);
            }

            // Check voter's Votes information.
            {
                var voterVotes = await ElectionContractStub.GetElectorVote.CallAsync(new StringValue
                {
                    Value = voterKeyPair.PublicKey.ToHex()
                });

                voterVotes.Pubkey.ShouldBe(ByteString.CopyFrom(voterKeyPair.PublicKey));
                voterVotes.ActiveVotingRecordIds.Count.ShouldBe(19);
                voterVotes.AllVotedVotesAmount.ShouldBe(actualVotedAmount);
                voterVotes.ActiveVotedVotesAmount.ShouldBe(actualVotedAmount);
                voterVotes.ActiveVotingRecords.Count.ShouldBe(0); // Not filled.

                var voterVotesWithRecords = await ElectionContractStub.GetElectorVoteWithRecords.CallAsync(
                    new StringValue
                {
                    Value = voterKeyPair.PublicKey.ToHex()
                });

                voterVotesWithRecords.ActiveVotingRecords.Count.ShouldBe(candidatesKeyPairs.Count);

                var voterVotesWithAllRecords = await ElectionContractStub.GetElectorVoteWithAllRecords.CallAsync(
                    new StringValue
                {
                    Value = voterKeyPair.PublicKey.ToHex()
                });

                voterVotesWithAllRecords.WithdrawnVotesRecords.Count.ShouldBe(0);
            }

            // Check candidate's Votes information.
            {
                //not exist
                var input = new StringValue
                {
                    Value = "FakePubkey"
                };
                var candidateVotesWithRecords = await ElectionContractStub.GetCandidateVoteWithRecords.CallAsync(input);

                candidateVotesWithRecords.ShouldBe(new CandidateVote());

                var candidateVotes = await ElectionContractStub.GetCandidateVote.CallAsync(new StringValue
                {
                    Value = candidateKeyPair.PublicKey.ToHex()
                });

                candidateVotes.Pubkey.ShouldBe(ByteString.CopyFrom(candidateKeyPair.PublicKey));
                candidateVotes.AllObtainedVotedVotesAmount.ShouldBe(amount * 2);
                candidateVotes.ObtainedActiveVotedVotesAmount.ShouldBe(amount * 2);
                candidateVotes.ObtainedWithdrawnVotesRecords.Count.ShouldBe(0); // Not filled.

                candidateVotesWithRecords = await ElectionContractStub.GetCandidateVoteWithRecords.CallAsync(
                    new StringValue
                {
                    Value = candidateKeyPair.PublicKey.ToHex()
                });

                candidateVotesWithRecords.ObtainedActiveVotingRecords.Count.ShouldBe(votersCount);

                var voterVotesWithAllRecords = await ElectionContractStub.GetCandidateVoteWithAllRecords.CallAsync(
                    new StringValue
                {
                    Value = candidateKeyPair.PublicKey.ToHex()
                });

                voterVotesWithAllRecords.ObtainedWithdrawnVotesRecords.Count.ShouldBe(0);
            }

            // Check voter's profit detail.
            {
                var welfareHash = ProfitItemsIds[ProfitType.CitizenWelfare];
                var details     = await ProfitContractStub.GetProfitDetails.CallAsync(new GetProfitDetailsInput
                {
                    SchemeId    = welfareHash,
                    Beneficiary = Address.FromPublicKey(votersKeyPairs.First().PublicKey)
                });

                details.Details.Count.ShouldBe(candidatesKeyPairs.Count);
            }

            return(candidatesKeyPairs);
        }
        public Value url_stat(Env env, StringValue path, LongValue flags)
        {
            env.warning(L.l("stat not supported by protocol"));

            return(BooleanValue.FALSE);
        }
Exemplo n.º 40
0
        private void Prepare(PropertyValueCollection propVals)
        {
            propVals.Clear();
            currentValues.Clear();

            // I do not trust the long-term stability of the PropertyValueCollection
            //
            // So what we do is load it up once with LiteralValue references and manipulate these
            // outside of the collection (via a cached dictionary). We cache everything from the wrapper API 
            // that can be cached in the managed world so that we only have minimal contact with it

            // Omit read-only properties
            using (FdoFeatureService service = _conn.CreateFeatureService())
            {
                ClassDefinition c = service.GetClassByName(this.ClassName);
                foreach (PropertyDefinition p in c.Properties)
                {
                    string name = p.Name;
                    PropertyValue pv = new PropertyValue(name, null);
                    if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                    {
                        DataPropertyDefinition d = p as DataPropertyDefinition;
                        if (!d.ReadOnly && !d.IsAutoGenerated) 
                        {
                            DataValue dv = null;
                            switch (d.DataType)
                            {
                                case DataType.DataType_BLOB:
                                    dv = new BLOBValue();
                                    break;
                                case DataType.DataType_Boolean:
                                    dv = new BooleanValue();
                                    break;
                                case DataType.DataType_Byte:
                                    dv = new ByteValue();
                                    break;
                                case DataType.DataType_CLOB:
                                    dv = new CLOBValue();
                                    break;
                                case DataType.DataType_DateTime:
                                    dv = new DateTimeValue();
                                    break;
                                case DataType.DataType_Decimal:
                                    dv = new DecimalValue();
                                    break;
                                case DataType.DataType_Double:
                                    dv = new DoubleValue();
                                    break;
                                case DataType.DataType_Int16:
                                    dv = new Int16Value();
                                    break;
                                case DataType.DataType_Int32:
                                    dv = new Int32Value();
                                    break;
                                case DataType.DataType_Int64:
                                    dv = new Int64Value();
                                    break;
                                case DataType.DataType_Single:
                                    dv = new SingleValue();
                                    break;
                                case DataType.DataType_String:
                                    dv = new StringValue();
                                    break;
                            }
                            if (dv != null)
                            {
                                pv.Value = dv;
                                propVals.Add(pv);
                            }
                        }
                    }
                    else if (p.PropertyType == PropertyType.PropertyType_GeometricProperty)
                    {
                        GeometricPropertyDefinition g = p as GeometricPropertyDefinition;
                        if (!g.ReadOnly)
                        {
                            GeometryValue gv = new GeometryValue();
                            pv.Value = gv;
                            propVals.Add(pv);
                        }
                    }
                }
                c.Dispose();
            }

            //Load property values into temp dictionary
            foreach (PropertyValue p in propVals)
            {
                currentValues[p.Name.Name] = p.Value as LiteralValue;
            }

            if (propertySnapshot == null)
            {
                propertySnapshot = new List<string>();
                foreach (PropertyValue p in propVals)
                {
                    propertySnapshot.Add(p.Name.Name);
                }
            }
        }
        public bool rename(Env env, StringValue path_from, StringValue path_to)
        {
            env.warning(L.l("rename not supported by protocol"));

            return(false);
        }
 public GenerateGridColumn(StringValue width)
 {
     this.width = width ?? throw new ArgumentNullException(nameof(width));
 }
        public Value opendir(Env env, StringValue path, LongValue flags)
        {
            env.warning(L.l("opendir not supported by protocol"));

            return(BooleanValue.FALSE);
        }
Exemplo n.º 44
0
        public static ValueTask <FluidValue> Raw(FluidValue input, FilterArguments arguments, TemplateContext context)
        {
            var stringValue = new StringValue(input.ToStringValue(), false);

            return(stringValue);
        }
Exemplo n.º 45
0
        /// <summary>
        /// Gets the values.
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ValueExpression> GetValues()
        {
            Dictionary<string, ValueExpression> values = new Dictionary<string, ValueExpression>();
            foreach (DataGridViewRow row in grdProperties.Rows)
            {
                string name = row.Cells[0].Value.ToString();
                PropertyDefinition propDef = row.Cells[0].Tag as PropertyDefinition;
                if (row.Cells[1].Value != null)
                {
                    string str = row.Cells[1].Value.ToString();
                    if (!string.IsNullOrEmpty(str))
                    {
                        ValueExpression expr = null;
                        if (propDef.PropertyType == PropertyType.PropertyType_DataProperty)
                        {
                            DataPropertyDefinition dp = propDef as DataPropertyDefinition;
                            switch (dp.DataType)
                            {
                                case DataType.DataType_Boolean:
                                    expr = new BooleanValue(Convert.ToBoolean(str));
                                    break;
                                case DataType.DataType_Byte:
                                    expr = new ByteValue(Convert.ToByte(str));
                                    break;
                                case DataType.DataType_DateTime:
                                    expr = new DateTimeValue(Convert.ToDateTime(str));
                                    break;
                                case DataType.DataType_Decimal:
                                    expr = new DecimalValue(Convert.ToDouble(str));
                                    break;
                                case DataType.DataType_Double:
                                    expr = new DoubleValue(Convert.ToDouble(str));
                                    break;
                                case DataType.DataType_Int16:
                                    expr = new Int16Value(Convert.ToInt16(str));
                                    break;
                                case DataType.DataType_Int32:
                                    expr = new Int32Value(Convert.ToInt32(str));
                                    break;
                                case DataType.DataType_Int64:
                                    expr = new Int64Value(Convert.ToInt64(str));
                                    break;
                                case DataType.DataType_Single:
                                    expr = new SingleValue(Convert.ToSingle(str));
                                    break;
                                case DataType.DataType_String:
                                    expr = new StringValue(str);
                                    break;
                                default:
                                    throw new NotSupportedException("Unsupported data type: " + dp.DataType);
                            }
                        }
                        else if (propDef.PropertyType == PropertyType.PropertyType_GeometricProperty)
                        {
                            FdoGeometryFactory fact = FdoGeometryFactory.Instance;
                            OSGeo.FDO.Geometry.IGeometry geom = fact.CreateGeometry(str);
                            byte[] fgf = fact.GetFgf(geom);
                            expr = new GeometryValue(fgf);
                            geom.Dispose();
                        }

                        if (expr != null)
                            values.Add(name, expr);
                    }
                }
            }
            return values;
        }
Exemplo n.º 46
0
 internal Property_Item_Description(PropertyRoot owner) : base(owner)
 {
     Value = new StringValue(this);
 }
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                // Value
                Value = new StringValue(EfsSystem.Instance.StringType, Image);
            }

            return retVal;
        }
Exemplo n.º 48
0
 public StringProperty(bool isMultiLine)
 {
     IsMultiLine = isMultiLine;
     Value       = StringValue.Select(x => (object)x).ToReactiveProperty();
 }
Exemplo n.º 49
0
        private static StringValue changeRowIndex(StringValue cellReference, int indexChange = 1)
        {
            var columnName = getColumnName(cellReference);
            var rowIndex = getRowIndex(cellReference);
            var newCellReference = columnName + (rowIndex + indexChange);

            return new StringValue(newCellReference);
        }
 public override MethodFees GetMethodFee(StringValue input)
 {
     return(State.TransactionFees[input.Value]);
 }
Exemplo n.º 51
0
        public static Font CreateFont(
            Fonts fonts,
            DoubleValue fontSize,
            UInt32Value color,
            StringValue fontName,
            Int32Value fontFamilyNumbering,
            Int32Value fontCharSet,
            bool isBold,
            bool isItalic,
            bool isUnderline,
            FontSchemeValues? fontScheme = null)
        {
            var font = new Font();

            font.Append(new FontSize { Val = fontSize });
            font.Append(new Color { Theme = color });
            font.Append(new FontName { Val = fontName });
            font.Append(new FontFamilyNumbering { Val = fontFamilyNumbering });
            font.Append(new FontCharSet { Val = fontCharSet });

            if (fontScheme.HasValue)
            {
                font.Append(new FontScheme { Val = fontScheme.Value });
            }
            if (isBold)
            {
                font.Append(new Bold());
            }
            if (isItalic)
            {
                font.Append(new Italic());
            }
            if (isUnderline)
            {
                font.Append(new Underline());
            }

            fonts.Append(font);

            return font;
        }
 public GenerateGridColumn()
 {
     this.width = "534";
 }
Exemplo n.º 53
0
        private static IRValueNode CreateConstant(ParseContext context) {
            TokenStream<RToken> tokens = context.Tokens;
            RToken currentToken = tokens.CurrentToken;
            IRValueNode term = null;

            switch (currentToken.TokenType) {
                case RTokenType.NaN:
                case RTokenType.Infinity:
                case RTokenType.Number:
                    term = new NumericalValue();
                    break;

                case RTokenType.Complex:
                    term = new ComplexValue();
                    break;

                case RTokenType.Logical:
                    term = new LogicalValue();
                    break;

                case RTokenType.String:
                    term = new StringValue();
                    break;

                case RTokenType.Null:
                    term = new NullValue();
                    break;

                case RTokenType.Missing:
                    term = new MissingValue();
                    break;
            }

            Debug.Assert(term != null);
            term.Parse(context, null);
            return term;
        }
Exemplo n.º 54
0
 public virtual T Visit(StringValue node)
 {
     return(Visit((ConstantValue)node));
 }
Exemplo n.º 55
0
        public CustomStylesheet()
        {
            Fonts fts = new Fonts();

            DocumentFormat.OpenXml.Spreadsheet.Font ft = new DocumentFormat.OpenXml.Spreadsheet.Font();
            FontName ftn = new FontName();

            ftn.Val = StringValue.FromString("Calibri");
            FontSize ftsz = new FontSize();

            ftsz.Val    = DoubleValue.FromDouble(11);
            ft.FontName = ftn;
            ft.FontSize = ftsz;
            fts.Append(ft);

            ft          = new DocumentFormat.OpenXml.Spreadsheet.Font();
            ftn         = new FontName();
            ftn.Val     = StringValue.FromString("Palatino Linotype");
            ftsz        = new FontSize();
            ftsz.Val    = DoubleValue.FromDouble(18);
            ft.FontName = ftn;
            ft.FontSize = ftsz;
            fts.Append(ft);

            fts.Count = UInt32Value.FromUInt32((uint)fts.ChildElements.Count);

            Fills       fills = new Fills();
            Fill        fill;
            PatternFill patternFill;

            fill                    = new Fill();
            patternFill             = new PatternFill();
            patternFill.PatternType = PatternValues.None;
            fill.PatternFill        = patternFill;
            fills.Append(fill);

            fill                    = new Fill();
            patternFill             = new PatternFill();
            patternFill.PatternType = PatternValues.Gray125;
            fill.PatternFill        = patternFill;
            fills.Append(fill);

            fill                            = new Fill();
            patternFill                     = new PatternFill();
            patternFill.PatternType         = PatternValues.Solid;
            patternFill.ForegroundColor     = new ForegroundColor();
            patternFill.ForegroundColor.Rgb = HexBinaryValue.FromString("00ff9728");
            patternFill.BackgroundColor     = new BackgroundColor();
            patternFill.BackgroundColor.Rgb = patternFill.ForegroundColor.Rgb;
            fill.PatternFill                = patternFill;
            fills.Append(fill);

            fills.Count = UInt32Value.FromUInt32((uint)fills.ChildElements.Count);

            Borders borders = new Borders();
            Border  border  = new Border();

            border.LeftBorder     = new LeftBorder();
            border.RightBorder    = new RightBorder();
            border.TopBorder      = new TopBorder();
            border.BottomBorder   = new BottomBorder();
            border.DiagonalBorder = new DiagonalBorder();
            borders.Append(border);

            //Boarder Index 1
            border                    = new Border();
            border.LeftBorder         = new LeftBorder();
            border.LeftBorder.Style   = BorderStyleValues.Thin;
            border.RightBorder        = new RightBorder();
            border.RightBorder.Style  = BorderStyleValues.Thin;
            border.TopBorder          = new TopBorder();
            border.TopBorder.Style    = BorderStyleValues.Thin;
            border.BottomBorder       = new BottomBorder();
            border.BottomBorder.Style = BorderStyleValues.Thin;
            border.DiagonalBorder     = new DiagonalBorder();
            borders.Append(border);


            //Boarder Index 2
            border                    = new Border();
            border.LeftBorder         = new LeftBorder();
            border.RightBorder        = new RightBorder();
            border.TopBorder          = new TopBorder();
            border.TopBorder.Style    = BorderStyleValues.Thin;
            border.BottomBorder       = new BottomBorder();
            border.BottomBorder.Style = BorderStyleValues.Thin;
            border.DiagonalBorder     = new DiagonalBorder();
            borders.Append(border);


            borders.Count = UInt32Value.FromUInt32((uint)borders.ChildElements.Count);

            CellStyleFormats csfs = new CellStyleFormats();
            CellFormat       cf   = new CellFormat();

            cf.NumberFormatId = 0;
            cf.FontId         = 0;
            cf.FillId         = 0;
            cf.BorderId       = 0;
            csfs.Append(cf);
            csfs.Count = UInt32Value.FromUInt32((uint)csfs.ChildElements.Count);

            uint             iExcelIndex = 164;
            NumberingFormats nfs         = new NumberingFormats();
            CellFormats      cfs         = new CellFormats();

            cf = new CellFormat();
            cf.NumberFormatId = 0;
            cf.FontId         = 0;
            cf.FillId         = 0;
            cf.BorderId       = 0;
            cf.FormatId       = 0;
            cfs.Append(cf);

            NumberingFormat nfDateTime = new NumberingFormat();

            nfDateTime.NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++);
            nfDateTime.FormatCode     = StringValue.FromString("dd/mm/yyyy hh:mm:ss");
            nfs.Append(nfDateTime);

            NumberingFormat nf4decimal = new NumberingFormat();

            nf4decimal.NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++);
            nf4decimal.FormatCode     = StringValue.FromString("#,##0.0000");
            nfs.Append(nf4decimal);

            // #,##0.00 is also Excel style index 4
            NumberingFormat nf2decimal = new NumberingFormat();

            nf2decimal.NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++);
            nf2decimal.FormatCode     = StringValue.FromString("#,##0.00");
            nfs.Append(nf2decimal);

            // @ is also Excel style index 49
            NumberingFormat nfForcedText = new NumberingFormat();

            nfForcedText.NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++);
            nfForcedText.FormatCode     = StringValue.FromString("@");
            nfs.Append(nfForcedText);

            // index 1
            // Format dd/mm/yyyy
            cf = new CellFormat();
            cf.NumberFormatId    = 14;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 2
            // Format #,##0.00
            cf = new CellFormat();
            cf.NumberFormatId    = 4;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 3
            cf = new CellFormat();
            cf.NumberFormatId    = nfDateTime.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 4
            cf = new CellFormat();
            cf.NumberFormatId    = nf4decimal.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 5
            cf = new CellFormat();
            cf.NumberFormatId    = nf2decimal.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 6
            cf = new CellFormat();
            cf.NumberFormatId    = nfForcedText.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 7
            // Header text
            cf = new CellFormat();
            cf.NumberFormatId    = nfForcedText.NumberFormatId;
            cf.FontId            = 1;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 8
            // column text
            cf = new CellFormat();
            cf.NumberFormatId    = nfForcedText.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 1;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 9
            // coloured 2 decimal text
            cf = new CellFormat();
            cf.NumberFormatId    = nf2decimal.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 2;
            cf.BorderId          = 2;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);

            // index 10
            // coloured column text
            cf = new CellFormat();
            cf.NumberFormatId    = nfForcedText.NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 2;
            cf.BorderId          = 2;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);


            nfs.Count = UInt32Value.FromUInt32((uint)nfs.ChildElements.Count);
            cfs.Count = UInt32Value.FromUInt32((uint)cfs.ChildElements.Count);

            this.Append(nfs);
            this.Append(fts);
            this.Append(fills);
            this.Append(borders);
            this.Append(csfs);
            this.Append(cfs);

            CellStyles css = new CellStyles();
            CellStyle  cs  = new CellStyle();

            cs.Name      = StringValue.FromString("Normal");
            cs.FormatId  = 0;
            cs.BuiltinId = 0;
            css.Append(cs);
            css.Count = UInt32Value.FromUInt32((uint)css.ChildElements.Count);
            this.Append(css);

            DifferentialFormats dfs = new DifferentialFormats();

            dfs.Count = 0;
            this.Append(dfs);

            TableStyles tss = new TableStyles();

            tss.Count             = 0;
            tss.DefaultTableStyle = StringValue.FromString("TableStyleMedium9");
            tss.DefaultPivotStyle = StringValue.FromString("PivotStyleLight16");
            this.Append(tss);
        }
Exemplo n.º 56
0
        /// <summary>
        ///  值的数据类型转换。
        /// </summary>
        /// <param name="value">要被转换的值</param>
        /// <param name="convertionType">要转换成哪种类型</param>
        /// <param name="groupID">数据库类型的组号</param>
        /// <returns></returns>
        internal object ChangeValue(object value, Type convertionType, int groupID, out Exception ex)
        {
            ex          = null;
            StringValue = Convert.ToString(value);
            if (value == null)
            {
                CellValue.IsNull = true;
                return(value);
            }
            if (groupID > 0 && StringValue == "")
            {
                CellValue.IsNull = true;
                return(null);
            }
            try
            {
                #region 类型转换
                if (groupID == 1)
                {
                    switch (StringValue)
                    {
                    case "正无穷大":
                        StringValue = "Infinity";
                        break;

                    case "负无穷大":
                        StringValue = "-Infinity";
                        break;
                    }
                }
                Type valueType = value.GetType();
                if (valueType.IsEnum && groupID == 1)
                {
                    if (convertionType.Name.StartsWith("Int"))
                    {
                        return((int)value);
                    }
                    return(Convert.ChangeType((int)value, convertionType));
                }
                if (valueType != convertionType)
                {
                    #region 折叠
                    switch (groupID)
                    {
                    case 0:
                        if (_CellStruct.SqlType == SqlDbType.Time)    //time类型的特殊处理。
                        {
                            string[] items = StringValue.Split(' ');
                            if (items.Length > 1)
                            {
                                StringValue = items[1];
                            }
                        }
                        value = StringValue;
                        break;

                    case 1:
                        switch (StringValue.ToLower())
                        {
                        case "true":
                            value = 1;
                            break;

                        case "false":
                            value = 0;
                            break;

                        case "infinity":
                            value = double.PositiveInfinity;
                            break;

                        case "-infinity":
                            value = double.NegativeInfinity;
                            break;

                        default:
                            goto err;
                        }
                        break;

                    case 2:
                        switch (StringValue.ToLower().TrimEnd(')', '('))
                        {
                        case "now":
                        case "getdate":
                        case "current_timestamp":
                            value = DateTime.Now;
                            break;

                        default:
                            DateTime dt = DateTime.Parse(StringValue);
                            value = dt == DateTime.MinValue ? (DateTime)SqlDateTime.MinValue : dt;
                            break;
                        }
                        break;

                    case 3:
                        switch (StringValue.ToLower())
                        {
                        case "yes":
                        case "true":
                        case "1":
                        case "on":
                        case "是":
                            value = true;
                            break;

                        case "no":
                        case "false":
                        case "0":
                        case "":
                        case "否":
                        default:
                            value = false;
                            break;
                        }
                        break;

                    case 4:
                        if (StringValue == SqlValue.Guid || StringValue.StartsWith("newid"))
                        {
                            value = Guid.NewGuid();
                        }
                        else
                        {
                            value = new Guid(StringValue);
                        }
                        break;

                    default:
err:
                        if (convertionType.Name.EndsWith("[]"))
                        {
                            value       = Convert.FromBase64String(StringValue);
                            StringValue = "System.Byte[]";
                        }
                        else
                        {
                            value = ConvertTool.ChangeType(value, convertionType);
                        }
                        break;
                    }
                    #endregion
                }
                //else if (groupID == 2 && strValue.StartsWith("000"))
                //{
                //    value = SqlDateTime.MinValue;
                //}
                #endregion
            }
            catch (Exception err)
            {
                value            = null;
                CellValue.Value  = null;
                CellValue.IsNull = true;
                ex = err;
                string msg = string.Format("ChangeType Error:ColumnName【{0}】({1}) , Value:【{2}】\r\n", _CellStruct.ColumnName, _CellStruct.ValueType.FullName, StringValue);
                StringValue = null;
                Log.Write(msg, LogType.Error);
            }
            return(value);
        }
Exemplo n.º 57
0
 /**
  * Adds a header.
  */
 public static Value header(Env env,
                            StringValue headerStr,
                            @Optional("true") bool replace,
Exemplo n.º 58
0
        /// <summary>
        /// Evaluates a dynamic member.
        /// </summary>
        /// <param name="Operand">Operand</param>
        /// <param name="Member">Member</param>
        /// <param name="NullCheck">If null should be returned if left operand is null.</param>
        /// <param name="Node">Script node.</param>
        /// <returns>Resulting value.</returns>
        public static IElement EvaluateDynamicMember(IElement Operand, IElement Member, bool NullCheck, ScriptNode Node)
        {
            if (Member.IsScalar)
            {
                StringValue s = Member as StringValue;
                if (s is null)
                {
                    throw new ScriptRuntimeException("Member names must be strings.", Node);
                }

                return(NamedMember.EvaluateDynamic(Operand, s.Value, NullCheck, Node));
            }
            else
            {
                if (Operand.IsScalar)
                {
                    LinkedList <IElement> Elements = new LinkedList <IElement>();

                    foreach (IElement E in Member.ChildElements)
                    {
                        Elements.AddLast(EvaluateDynamicMember(Operand, E, NullCheck, Node));
                    }

                    return(Member.Encapsulate(Elements, Node));
                }
                else
                {
                    ICollection <IElement> OperandElements = Operand.ChildElements;
                    ICollection <IElement> MemberElements  = Member.ChildElements;

                    if (OperandElements.Count == MemberElements.Count)
                    {
                        LinkedList <IElement>  Elements = new LinkedList <IElement>();
                        IEnumerator <IElement> eOperand = OperandElements.GetEnumerator();
                        IEnumerator <IElement> eMember  = MemberElements.GetEnumerator();

                        try
                        {
                            while (eOperand.MoveNext() && eMember.MoveNext())
                            {
                                Elements.AddLast(EvaluateDynamicMember(eOperand.Current, eMember.Current, NullCheck, Node));
                            }
                        }
                        finally
                        {
                            eOperand.Dispose();
                            eMember.Dispose();
                        }

                        return(Operand.Encapsulate(Elements, Node));
                    }
                    else
                    {
                        LinkedList <IElement> OperandResult = new LinkedList <IElement>();

                        foreach (IElement OperandChild in OperandElements)
                        {
                            LinkedList <IElement> MemberResult = new LinkedList <IElement>();

                            foreach (IElement MemberChild in MemberElements)
                            {
                                MemberResult.AddLast(EvaluateDynamicMember(OperandChild, MemberChild, NullCheck, Node));
                            }

                            OperandResult.AddLast(Member.Encapsulate(MemberResult, Node));
                        }

                        return(Operand.Encapsulate(OperandResult, Node));
                    }
                }
            }
        }
Exemplo n.º 59
0
 internal virtual Value PlusString(StringValue value)
 {
     throw new InvalidOperationException(CreateMessage(Operation.Add, value, this));
 }
Exemplo n.º 60
0
        private static Stylesheet GenerateStyleSheet()
        {
            //  If you want certain Excel cells to have a different Format, color, border, fonts, etc, then you need to define a "CellFormats" records containing
            //  these attributes, then assign that style number to your cell.
            //
            //  For example, we'll define "Style # 3" with the attributes we'd like for our header row (Row #1) on each worksheet, where the text is a bit bigger,
            //  and is white text on a dark-gray background.
            //
            //  NB: The NumberFormats from 0 to 163 are hardcoded in Excel (described in the following URL), and we'll define a couple of custom number formats below.
            //  https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.numberingformat.aspx
            //  http://lateral8.com/articles/2010/6/11/openxml-sdk-20-formatting-excel-values.aspx
            //
            uint iExcelIndex = 164;

            return(new Stylesheet(
                       new NumberingFormats(
                           //
                           new NumberingFormat()                                            // Custom number format # 164: especially for date-times
            {
                NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++),
                FormatCode = StringValue.FromString("dd/MMM/yyyy hh:mm:ss")
            },
                           new NumberingFormat()                                            // Custom number format # 165: especially for date times (with a blank time)
            {
                NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++),
                FormatCode = StringValue.FromString("dd/MMM/yyyy")
            }
                           ),
                       new Fonts(
                           new Font(                                                        // Index 0 - The default font.
                               new FontSize()
            {
                Val = 10
            },
                               new Color()
            {
                Rgb = new HexBinaryValue()
                {
                    Value = "000000"
                }
            },
                               new FontName()
            {
                Val = "Arial"
            }),
                           new Font(                                                        // Index 1 - A 12px bold font, in white.
                               new Bold(),
                               new FontSize()
            {
                Val = 12
            },
                               new Color()
            {
                Rgb = new HexBinaryValue()
                {
                    Value = "FFFFFF"
                }
            },
                               new FontName()
            {
                Val = "Arial"
            }),
                           new Font(                                                        // Index 2 - An Italic font.
                               new Italic(),
                               new FontSize()
            {
                Val = 10
            },
                               new Color()
            {
                Rgb = new HexBinaryValue()
                {
                    Value = "000000"
                }
            },
                               new FontName()
            {
                Val = "Times New Roman"
            })
                           ),
                       new Fills(
                           new Fill(                                                    // Index 0 - The default fill.
                               new PatternFill()
            {
                PatternType = PatternValues.None
            }),
                           new Fill(                                                    // Index 1 - The default fill of gray 125 (required)
                               new PatternFill()
            {
                PatternType = PatternValues.Gray125
            }),
                           new Fill(                                                    // Index 2 - The yellow fill.
                               new PatternFill(
                                   new ForegroundColor()
            {
                Rgb = new HexBinaryValue()
                {
                    Value = "FFFFFF00"
                }
            }
                                   )
            {
                PatternType = PatternValues.Solid
            }),
                           new Fill(                                                    // Index 3 - Dark-gray fill.
                               new PatternFill(
                                   new ForegroundColor()
            {
                Rgb = new HexBinaryValue()
                {
                    Value = "FF404040"
                }
            }
                                   )
            {
                PatternType = PatternValues.Solid
            })
                           ),
                       new Borders(
                           new Border(                                                  // Index 0 - The default border.
                               new LeftBorder(),
                               new RightBorder(),
                               new TopBorder(),
                               new BottomBorder(),
                               new DiagonalBorder()),
                           new Border(                                                  // Index 1 - Applies a Left, Right, Top, Bottom border to a cell
                               new LeftBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                               new RightBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                               new TopBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                               new BottomBorder(new Color()
            {
                Auto = true
            })
            {
                Style = BorderStyleValues.Thin
            },
                               new DiagonalBorder())
                           ),
                       new CellFormats(
                           new CellFormat()
            {
                FontId = 0, FillId = 0, BorderId = 0
            },                                                                                         // Style # 0 - The default cell style.  If a cell does not have a style index applied it will use this style combination instead
                           new CellFormat()
            {
                NumberFormatId = 164
            },                                                                                         // Style # 1 - DateTimes
                           new CellFormat()
            {
                NumberFormatId = 165
            },                                                                                         // Style # 2 - Dates (with a blank time)
                           new CellFormat(new Alignment()
            {
                Horizontal = HorizontalAlignmentValues.Center, Vertical = VerticalAlignmentValues.Center
            })
            {
                FontId = 1, FillId = 3, BorderId = 0, ApplyFont = true, ApplyAlignment = true
            },                                                                                                   // Style # 3 - Header row
                           new CellFormat()
            {
                NumberFormatId = 3
            },                                                                                         // Style # 4 - Number format: #,##0
                           new CellFormat()
            {
                NumberFormatId = 4
            },                                                                                         // Style # 5 - Number format: #,##0.00
                           new CellFormat()
            {
                FontId = 1, FillId = 0, BorderId = 0, ApplyFont = true
            },                                                                                         // Style # 6 - Bold
                           new CellFormat()
            {
                FontId = 2, FillId = 0, BorderId = 0, ApplyFont = true
            },                                                                                         // Style # 7 - Italic
                           new CellFormat()
            {
                FontId = 2, FillId = 0, BorderId = 0, ApplyFont = true
            },                                                                                         // Style # 8 - Times Roman
                           new CellFormat()
            {
                FontId = 0, FillId = 2, BorderId = 0, ApplyFill = true
            },                                                                                         // Style # 9 - Yellow Fill
                           new CellFormat(                                                             // Style # 10 - Alignment
                               new Alignment()
            {
                Horizontal = HorizontalAlignmentValues.Center, Vertical = VerticalAlignmentValues.Center
            }
                               )
            {
                FontId = 0, FillId = 0, BorderId = 0, ApplyAlignment = true
            },
                           new CellFormat()
            {
                FontId = 0, FillId = 0, BorderId = 1, ApplyBorder = true
            }              // Style # 11 - Border
                           )
                       )); // return
        }