示例#1
0
            public IList <IList <string> > GroupAnagrams(string[] strs)
            {
                var rs = new List <IList <string> >();

                if (strs == null || strs.Length == 0)
                {
                    return(rs);
                }
                var dict = new Dictionary <StringWrapper, List <StringWrapper> >();

                foreach (var str in strs)
                {
                    var wrapper = new StringWrapper
                    {
                        Val = str
                    };
                    if (!dict.ContainsKey(wrapper))
                    {
                        dict[wrapper] = new List <StringWrapper>();
                    }

                    dict[wrapper].Add(wrapper);
                }

                foreach (var entry in dict)
                {
                    rs.Add(entry.Value.ConvertAll(input => input.Val));
                }

                return(rs);
            }
        /// <summary>
        /// Get a list of GpuDeviceInfo for GPUs found on this machine.
        /// </summary>
        /// <returns>List of GpuDeviceInfo</returns>
        static public List <GpuDeviceInfo> GpuDeviceInfos()
        {
            List <string>        gpuNames       = GpuNames();
            List <GpuDeviceInfo> gpuDeviceInfos = new List <GpuDeviceInfo>(gpuNames.Count);

            for (int i = 0; i < gpuNames.Count; i++)
            {
                ulong memory = UnsafeNativeMethods.RhCmn_DisplayDeviceInfo_GetGpuMemoryAsInt(i);
                using (var vendorName = new StringWrapper("")) {
                    using (var memoryAsString = new StringWrapper("")) {
                        using (var driverDateAsString = new StringWrapper("")) {
                            UnsafeNativeMethods.RhCmn_DisplayDeviceInfo_GetGpuVendorAsString(i, vendorName.NonConstPointer);
                            UnsafeNativeMethods.RhCmn_DisplayDeviceInfo_GetGpuMemoryAsString(i, memoryAsString.NonConstPointer);
                            UnsafeNativeMethods.RhCmn_DisplayDeviceInfo_GetGpuDriverDateAsString(i, driverDateAsString.NonConstPointer);
                            gpuDeviceInfos.Add(
                                new GpuDeviceInfo(
                                    gpuNames[i],
                                    vendorName.ToString(),
                                    memory,
                                    memoryAsString.ToString(),
                                    driverDateAsString.ToString()
                                    )
                                );
                        }
                    }
                }
            }

            return(gpuDeviceInfos);
        }
示例#3
0
        private void button3_Click(object sender, EventArgs e)
        {
            //Open bone selector for collision rigging
            StringWrapper str = new StringWrapper()
            {
                data = currentEntry.boneName
            };
            BoneRiggingSelector bs = new BoneRiggingSelector(str);

            bs.ShowDialog();
            currentEntry.boneName = str.data;
            string boneNameRigging = "";

            foreach (char b in currentEntry.boneName)
            {
                if (b != (char)0)
                {
                    boneNameRigging += b;
                }
            }
            if (boneNameRigging.Length == 0)
            {
                boneNameRigging = "None";
            }
            button3.Text = boneNameRigging;
        }
    void Awake()
    {
        // Initialize String
        stringWrapper = new StringWrapper(null, camera, reorientBranding, fullscreen, alignment);

        // Load some image targets
        for (uint i = 0; i < rootObjects.Length; i++)
        {
            stringWrapper.LoadImageMarker("Marker " + (i + 1), "png");
        }

        // Hide all rootObjects
        // Also, set them as children of the camera;
        // This is to more easily position them relative to the camera later
        for (uint i = 0; i < rootObjects.Length; i++)
        {
            rootObjects[i].SetActiveRecursively(false);
            rootObjects[i].transform.parent = transform;
        }

        // Allocate array to track the last time each marker was spotted
        lastSpottedTimes = new float[rootObjects.Length];

        // Prevent the iOS keyboard from introducing an unwanted
        // black frame when rotating
        iPhoneKeyboard.autorotateToLandscapeLeft = false;
        iPhoneKeyboard.autorotateToLandscapeRight = false;
        iPhoneKeyboard.autorotateToPortrait = false;
        iPhoneKeyboard.autorotateToPortraitUpsideDown = false;
    }
示例#5
0
        protected override void OnPreRender(EventArgs e) {

            if (Path.HasExtension(ImageUrl) || ImageUrl.EndsWith(Path.AltDirectorySeparatorChar.ToString()) || ImageUrl.EndsWith(Path.DirectorySeparatorChar.ToString())) {
                ImageUrl = Path.GetDirectoryName(ImageUrl);
            }

            string cssFileName = ImageOptimizations.LinkCompatibleCssFile(new HttpContextWrapper(Context).Request.Browser) ?? ImageOptimizations.LowCompatibilityCssFile;

            // Set up fileName and path variables
            string localPath = Context.Server.MapPath(ImageUrl);

            // Check that CSS file is accessible
            if (!File.Exists(Path.Combine(localPath, cssFileName))) {
                return;
            }

            // Have to change directory separator character because the ImageSprite method uses Path.GetDirectory, which uses backslashes
            StringWrapper key = new StringWrapper(ImageUrl.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));

            if (!Page.Items.Contains(key)) {
                Page.Items.Add(key, null);

                HtmlLink css = new HtmlLink();
                css.Href = Path.Combine(ImageUrl, cssFileName);
                css.Attributes["rel"] = "stylesheet";
                css.Attributes["type"] = "text/css";
                css.Attributes["media"] = "all";
                Page.Header.Controls.Add(css);
            }
        }
示例#6
0
        bool SubProcessCheckRemainingBatteryCapacity(StringWrapper log)
        {
            var batteries = new List <IMyBatteryBlock>();

            GridTerminalSystem.GetBlocksOfType(batteries, blk => CollectSameConstruct(blk) && blk.IsFunctional && blk.Enabled);
            if (batteries.Count() > 0)
            {
                float remainingCapacity = RemainingBatteryCapacity(batteries);
                if (remainingCapacity < CriticalBatteryCapacity)
                {
                    log.Append("Critical power detected");
                    criticalBatteryCapacityDetected = true;
                    var timerblocks = new List <IMyTimerBlock>();
                    GridTerminalSystem.GetBlocksOfType(timerblocks, tb => MyIni.HasSection(tb.CustomData, TriggerOnCriticalCurrentDetectedTag));
                    timerblocks.ForEach(tb => tb.Trigger());

                    // disable blocks with DisableOnEmergencyTag
                    DisableBlocks(blk => MyIni.HasSection(blk.CustomData, DisableOnEmergencyTag));
                    informationTerminals.Text = string.Format("Critical power detected");
                }
                else if (criticalBatteryCapacityDetected)
                {
                    criticalBatteryCapacityDetected = false;
                    var timerblocks = new List <IMyTimerBlock>();
                    GridTerminalSystem.GetBlocksOfType(timerblocks, tb => MyIni.HasSection(tb.CustomData, TriggerOnNormalCurrentReestablishedTag));
                    timerblocks.ForEach(tb => tb.Trigger());

                    // enable blocks with DisableOnEmergencyTag
                    EnableBlocks(blk => MyIni.HasSection(blk.CustomData, DisableOnEmergencyTag));
                }

                log.Append(string.Format("Battery capacity: {0}%", Math.Round(remainingCapacity * 100, 0)));
            }
            return(true);
        }
        private static NameWrapper AddNameToUniqueStrings(string name, Dictionary <string, string> dontShortenStrings,
                                                          CaseInsensitiveDictionary <StringWrapper> uniqueStrings)
        {
            NameWrapper nameWrapper = new NameWrapper();

            List <string> nameStrings = StringUtils.SplitAndReallyRemoveEmptyEntries(name, Utils.NAME_SEPARATOR, StringComparison.OrdinalIgnoreCase);

            foreach (string nameString in nameStrings)
            {
                bool          canShorten = !dontShortenStrings.ContainsKey(nameString);
                StringWrapper stringWrapper;
                if (uniqueStrings.TryGetValue(nameString, out stringWrapper))
                {
                    DebugUtils.AssertDebuggerBreak(stringWrapper.CanShorten == canShorten);
                }
                else
                {
                    stringWrapper = new StringWrapper(nameString, canShorten);
                    uniqueStrings.Add(nameString, stringWrapper);
                }
                nameWrapper.AddString(stringWrapper);
            }

            return(nameWrapper);
        }
        public void GivenIComparableImplementedAndNotZeroThenAreEquivalentShouldReturnFalse()
        {
            var source = new StringWrapper(true).AsConstantExpression();
            var target = new StringWrapper(true).AsConstantExpression();

            Assert.False(eq.AreEquivalent(source, target));
        }
示例#9
0
    public void ShowQuestion(TestQuestion question)
    {
        ShowTestTitle();
        txtQuestion.Buffer.Text = question.Text;
        // Clean previous answers
        foreach (var child in AnswersHolder.Children)
        {
            child.Destroy();
        }
        // Create new answer items
        answers = new CheckButton[question.Answers.Count];
        // Get user selected items
        var answered = results.Answered(question);

        for (int i = 0; i < question.Answers.Count; ++i)
        {
            answers [i] = new CheckButton();
            var display    = this.Display.GetScreen(0);
            int fntSize    = (int)(answers [i].PangoContext.FontDescription.Size / Pango.Scale.PangoScale);
            int maxSymbols = display.Width / fntSize;
            answers [i].Label = StringWrapper.WordWrap(question.Answers[i].Text, maxSymbols);
            AnswersHolder.Add(answers[i]);
            // Show answers already checked by user
            foreach (var answer in answered)
            {
                if (answer == question.Answers [i])
                {
                    answers [i].Active = true;
                }
            }
        }
        AnswersHolder.ShowAll();
        // Fix focus
        FocusGrabbedByTextQuestion(null, null);
    }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rtf_str"></param>
        /// <param name="bold"></param>
        /// <param name="italic"></param>
        /// <param name="underline"></param>
        /// <param name="facename"></param>
        /// <returns></returns>
        ///     [Obsolete("Use AnnotationBase.FirstCharFont instead")]
        /// <since>6.0</since>
        static public bool FirstCharProperties(string rtf_str, ref bool bold, ref bool italic, ref bool underline, ref string facename)
        {
            if (null == rtf_str)
            {
                return(false);
            }
            int  props = 0;
            bool rc    = false;

            using (var sw = new StringWrapper())
            {
                sw.SetString(facename);
                var ptr_facename = sw.NonConstPointer;
                props = UnsafeNativeMethods.ON_Annotation_FirstCharTextProperties(rtf_str, ptr_facename);
                if (1 == (props & 1))
                {
                    bold      = 2 == (props & 2);
                    italic    = 4 == (props & 4);
                    underline = 8 == (props & 8);
                    facename  = sw.ToString();
                    rc        = true;
                }
            }
            return(rc);
        }
示例#11
0
        public FDesktop(IEmailer emailer, ImageSaver imageSaver, StringWrapper stringWrapper, AppConfigManager appConfigManager, RecoveryManager recoveryManager, IScannedImageImporter scannedImageImporter, AutoUpdaterUI autoUpdaterUI, OcrDependencyManager ocrDependencyManager, IProfileManager profileManager, IScanPerformer scanPerformer, IScannedImagePrinter scannedImagePrinter, ChangeTracker changeTracker, EmailSettingsContainer emailSettingsContainer, FileNamePlaceholders fileNamePlaceholders, ImageSettingsContainer imageSettingsContainer, PdfSettingsContainer pdfSettingsContainer, PdfSaver pdfSaver, IErrorOutput errorOutput)
        {
            this.emailer                = emailer;
            this.imageSaver             = imageSaver;
            this.stringWrapper          = stringWrapper;
            this.appConfigManager       = appConfigManager;
            this.recoveryManager        = recoveryManager;
            this.scannedImageImporter   = scannedImageImporter;
            this.autoUpdaterUI          = autoUpdaterUI;
            this.ocrDependencyManager   = ocrDependencyManager;
            this.profileManager         = profileManager;
            this.scanPerformer          = scanPerformer;
            this.scannedImagePrinter    = scannedImagePrinter;
            this.changeTracker          = changeTracker;
            this.emailSettingsContainer = emailSettingsContainer;
            this.fileNamePlaceholders   = fileNamePlaceholders;
            this.imageSettingsContainer = imageSettingsContainer;
            this.pdfSettingsContainer   = pdfSettingsContainer;
            this.pdfSaver               = pdfSaver;
            this.errorOutput            = errorOutput;
            InitializeComponent();

            thumbnailList1.MouseWheel += thumbnailList1_MouseWheel;
            Shown       += FDesktop_Shown;
            FormClosing += FDesktop_FormClosing;
            Closed      += FDesktop_Closed;
        }
示例#12
0
 // Function to add text to the battle text. Only adds text when the debug option is turned on
 // Otherwise the auto battle and normal battles will take too long accumulate and display all the text.
 // Purely for debug purposes.
 public void AddTxt(StringWrapper s)
 {
     if (Auto)
     {
         SaveScore.BattleText.Add(s);
     }
 }
示例#13
0
 private static bool TryGetStringWrapper(ExpressionSyntax expression, out StringWrapper stringWrapper)
 {
     if (expression is LiteralExpressionSyntax literal && literal.IsKind(SyntaxKind.StringLiteralExpression))
     {
         stringWrapper = new StringWrapper(literal, literal.Token.ValueText);
         return(true);
     }
示例#14
0
            public StringWrapper AddNewLog()
            {
                StringWrapper stringWrapper = new StringWrapper();

                _logs.Add(stringWrapper);
                return(stringWrapper);
            }
示例#15
0
        private void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
        {
            // If result is secondary, we want to close anyway
            if (args.Result == ContentDialogResult.Secondary)
            {
                doNotClose = false;
            }
            else
            {
                // Don't really like this here but...
                if (resultsListView.SelectedItem != null)
                {
                    // only including model to cast
                    StringWrapper wrapper = resultsListView.SelectedItem as StringWrapper;
                    if (!string.IsNullOrEmpty(wrapper.StringContent))
                    {
                        args.Cancel = false;
                    }
                }
            }

            if (doNotClose)
            {
                args.Cancel = true;
            }
        }
 private RESULT OpenedCallback(StringWrapper name, ref uint filesize, ref IntPtr handle, IntPtr userdata)
 {
     if (_opened != null)
     {
         _opened(name, filesize, handle);
     }
     return(RESULT.OK);
 }
示例#17
0
        private static void WatchHook(IntPtr pointerToIRhinoFileEventWatcher, IntPtr pathWStringPointer, IntPtr filterWStringPointer)
        {
            AttachHook(pointerToIRhinoFileEventWatcher);
            var path   = StringWrapper.GetStringFromPointer(pathWStringPointer);
            var filter = StringWrapper.GetStringFromPointer(filterWStringPointer);

            g_watchers[pointerToIRhinoFileEventWatcher].Watch(path, filter);
        }
    void Awake()
    {
        // Initialize String
        stringWrapper = new StringWrapper(previewCamName, previewCamApproxVerticalFOV, camera, reorientIPhoneSplash, fullscreen, alignment);

        // Load some image targets
        stringWrapper.LoadImageMarker("Marker 1", "png");
    }
示例#19
0
    void Awake()
    {
        // Initialize String
        stringWrapper = new StringWrapper(previewCamName, previewCamApproxVerticalFOV, camera, reorientIPhoneSplash, fullscreen, alignment);

        // Load some image targets
        stringWrapper.LoadImageMarker("Marker 1", "png");
    }
示例#20
0
        private IStringBuilder CreateStringBuilderWrapper()
        {
            const string anyString = "Something here";

            var wrapper = new StringWrapper(anyString);

            return(wrapper.CreateNewBuilder());
        }
示例#21
0
        public void TestThatWrappedStringYieldsOriginalString()
        {
            const string anyString = "Something here";

            var wrapper = new StringWrapper(anyString);

            wrapper.Content.Should().Be(anyString);
            wrapper.ToString().Should().Be(anyString);
        }
示例#22
0
 public ClientBaseForm()
 {
     InitializeComponent();
     lbl_viewedObject.Text          = "";
     _endPointConfigurationNameList = new List <string>();
     pg_objectViewer.PropertySort   = PropertySort.NoSort;
     ReturnValueInt    = new IntWrapper();
     ReturnValueString = new StringWrapper();
     ShipmentTest      = new BaseShipment();
 }
示例#23
0
        public void Test1()
        {
            var strwr = new StringWrapper();

            strwr.str = "print(1+2)\r\nprint(3+5)";
            var res      = pipe.Exec(strwr).str;
            var reslines = res.Lines().ToArray();

            Assert.True(reslines.Length == 2 && reslines[0] == "3" && reslines[1] == "8");
        }
示例#24
0
 /// <summary>
 /// Format a Volume string from a number
 /// </summary>
 /// <param name="volume"></param>
 /// <param name="units"></param>
 /// <param name="dimStyle"></param>
 /// <param name="alternate"></param>
 /// <returns></returns>
 /// <since>7.0</since>
 public static string FormatVolume(double volume, UnitSystem units, Pixel.Rhino.DocObjects.DimensionStyle dimStyle, bool alternate)
 {
     using (var sw = new StringWrapper())
     {
         IntPtr pString            = sw.NonConstPointer;
         IntPtr const_ptr_dimstyle = dimStyle == null ? IntPtr.Zero : dimStyle.ConstPointer();
         UnsafeNativeMethods.ON_TextContext_FormatVolume(volume, units, const_ptr_dimstyle, alternate, pString);
         return(sw.ToString());
     }
 }
示例#25
0
 /// <summary> Return text string for this annotation </summary>
 /// <param name="rich">
 /// If true, the string will include RTF formatting information.
 /// If false, the 'plain' form of the text will be returned.
 /// </param>
 string GetText(bool rich)
 {
     using (var sw = new StringWrapper())
     {
         var    ptr_stringholder = sw.NonConstPointer;
         IntPtr const_ptr_this   = ConstPointer();
         UnsafeNativeMethods.ON_V6_Annotation_GetTextString(const_ptr_this, ptr_stringholder, rich);
         return(sw.ToString());
     }
 }
示例#26
0
 /// <summary> Return plain text string for this annotation with field expressions unevaluated </summary>
 string GetPlainTextWithFields()
 {
     using (var sw = new StringWrapper())
     {
         var    ptr_stringholder = sw.NonConstPointer;
         IntPtr const_ptr_this   = ConstPointer();
         UnsafeNativeMethods.ON_V6_Annotation_GetPlainTextWithFields(const_ptr_this, ptr_stringholder);
         return(sw.ToString());
     }
 }
示例#27
0
 public Task PutComplexPrimitiveString() => TestStatus(async(host, pipeline) =>
 {
     var value = new StringWrapper
     {
         Field        = "goodrequest",
         Empty        = string.Empty,
         NullProperty = null
     };
     return(await new PrimitiveClient(ClientDiagnostics, pipeline, host).PutStringAsync(value));
 });
示例#28
0
        public WMSFacade()
        {
            client = new HttpClient();
            string webapiurl = StringWrapper.GetAppSettingValue("WebApiUrl");

            if (string.IsNullOrEmpty(webapiurl))
            {
                webapiurl = "http://localhost/BFM.WebApiService/"; //本地默认地址
            }
            client.BaseAddress = new Uri(webapiurl);
        }
示例#29
0
 public static void Echo(
     this StringWrapper obj,
     EchoEvaluationContext ctx)
 {
     var(@out, context, _) = ctx;
     if (context.EchoMap.MappedCall(obj, ctx))
     {
         return;
     }
     @out.Echo(obj.ToString());
 }
        public void GivenIComparableImplementedAndZeroThenAreEquivalentShouldReturnTrue()
        {
            var source = new StringWrapper(true).AsConstantExpression();
            var target = new StringWrapper
            {
                Id    = ((StringWrapper)source.Value).Id,
                IdVal = ((StringWrapper)source.Value).IdVal
            }.AsConstantExpression();

            Assert.True(eq.AreEquivalent(source, target));
        }
示例#31
0
        public void PipeString()
        {
            var pipeline =
                new Pipeline <StringWrapper>()
                .Add(new PrefixSuffixContent("Hello"))
                .Add(new PrefixSuffixContent("World"));

            StringWrapper initialValue = "";

            pipeline.Execute(initialValue);
            Assert.Equal("HelloWorldWorldHello", initialValue.Content);
        }
示例#32
0
        public void TestThatImplicitOperatorsPreserveNullness()
        {
            string nullString = null;

            StringWrapper wrapper = nullString;

            wrapper.Should().BeNull();

            string unwrapped = wrapper;

            unwrapped.Should().BeNull();
        }
示例#33
0
    // Use this for initialization
    IEnumerator Start()
    {
        ordersRetrieved = new List <Order>();

        yield return(StartCoroutine(GetAccessToken((tokenResult) =>
        {
            acces_token = tokenResult;
        })));

        Debug.Log("Token is : " + acces_token.token);
        GetOrders();
    }
    void Awake()
    {
        // Initialize String
        stringWrapper = new StringWrapper(null, camera, reorientBranding, fullscreen, alignment);

        // Load some image targets
        for (uint i = 0; i < markerObjects.Length; i++)
        {
            stringWrapper.LoadImageMarker("Marker " + (i + 1), "png");
        }

        // Prevent the iOS keyboard from introducing an unwanted
        // black frame when rotating
        iPhoneKeyboard.autorotateToLandscapeLeft = false;
        iPhoneKeyboard.autorotateToLandscapeRight = false;
        iPhoneKeyboard.autorotateToPortrait = false;
        iPhoneKeyboard.autorotateToPortraitUpsideDown = false;
    }
    void Awake()
    {
        // Initialize String
        stringWrapper = new StringWrapper(previewCamName, previewCamApproxVerticalFOV, camera, reorientIPhoneSplash, fullscreen, alignment);

        // Load some image targets
        stringWrapper.LoadImageMarker("Marker 1", "png");

        // Hide all rootObjects
        // Also, set them as children of the camera;
        // This is to more easily position them relative to the camera later
        for (uint i = 0; i < rootObjects.Length; i++)
        {
            rootObjects[i].SetActiveRecursively(false);
            rootObjects[i].transform.parent = transform;
        }

        // Allocate array to track the last time each marker was spotted
        lastSpottedTimes = new float[rootObjects.Length];
    }
示例#36
0
        protected override void OnPreRender(EventArgs e) {

            if (!EnableSprites) {
                return;
            }

            string cssFileName = ImageOptimizations.LinkCompatibleCssFile(new HttpContextWrapper(Context).Request.Browser);
            if (cssFileName == null) {
                return;
            }

            try {
                string webPath = Path.GetDirectoryName(ImageUrl);

                // Check that CSS file is accessible
                if (!File.Exists(Path.Combine(Context.Server.MapPath(webPath), cssFileName))) {
                    return;
                }

                // A new class is used to avoid conflicts in Page.Items
                StringWrapper key = new StringWrapper(webPath);

                if (!Page.Items.Contains(key)) {
                    Page.Items.Add(key, null);

                    HtmlLink css = new HtmlLink();
                    css.Href = Path.Combine(webPath, cssFileName);
                    css.Attributes["rel"] = "stylesheet";
                    css.Attributes["type"] = "text/css";
                    css.Attributes["media"] = "all";
                    Page.Header.Controls.Add(css);
                }

                string imagefileName = Path.GetFileName(ImageUrl);
                CssClass = ImageOptimizations.MakeCssClassName(Path.Combine(webPath, imagefileName), (string)HttpRuntime.Cache.Get("spriteFolderRelativePath"));
                ImageUrl = ImageOptimizations.InlinedTransparentGif;
            }
            catch (Exception) {
                // If an exception occured, use a normal image tag in place of the sprite
            }
        }
 /// <summary>
 /// Test explicitly required string. Please put a valid string-wrapper with
 /// 'value' = null and the client library should throw before the request is
 /// sent.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='bodyParameter'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<Error> PostRequiredStringPropertyAsync( this IExplicitModel operations, StringWrapper bodyParameter, CancellationToken cancellationToken = default(CancellationToken))
 {
     HttpOperationResponse<Error> result = await operations.PostRequiredStringPropertyWithHttpMessagesAsync(bodyParameter, null, cancellationToken).ConfigureAwait(false);
     return result.Body;
 }
 /// <summary>
 /// Test explicitly required string. Please put a valid string-wrapper with
 /// 'value' = null and the client library should throw before the request is
 /// sent.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='bodyParameter'>
 /// </param>
 public static Error PostRequiredStringProperty(this IExplicitModel operations, StringWrapper bodyParameter)
 {
     return Task.Factory.StartNew(s => ((IExplicitModel)s).PostRequiredStringPropertyAsync(bodyParameter), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
示例#39
0
 /// <summary>
 /// Put complex types with string properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 'goodrequest', '', and null
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task PutStringAsync(this IPrimitive operations, StringWrapper complexBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     await operations.PutStringWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false);
 }
            public StringWrapper Remove(int index, int count)
            {
                StringWrapper returner = new StringWrapper(Str);
                if (count <= 0) return returner;

                bool wChar;
                int i = returner.ToRealIndex(index, out wChar);
                returner.Str = returner.Str.Remove(i, wChar ? 2 : 1);
                return returner.Remove(index, count - (wChar ? 2 : 1));
            }
        private string Obfuscate(string sParam)
        {
            StringWrapper s = new StringWrapper(sParam);
            Random rand = new Random();
            s = s.Length + ":" + s;
            while (s.Length % 32 > 0)
            {
                int i = rand.Next('z' - 'a' + 'Z' - 'A' + '9' - '0');
                i -= 'z' - 'a';
                if (i < 0)
                    s += (char)('a' + rand.Next('z' - 'a'));
                else
                {
                    i -= 'Z' - 'A';
                    if (i < 0)
                        s += (char) ('A' + rand.Next('Z' - 'A'));
                    else
                        s += (char) ('0' + rand.Next('9' - '0'));

                }
            }

            StringWrapper output = new StringWrapper("");

            int phase1 = 0;
            int phase2 = 0;
            while (s.Length > 0)
            {
                string ch = "";
                switch (phase1)
                {
                    case 0:
                        ch = s[0];
                        s = s.Remove(0, 1);
                        break;
                    case 1:
                        ch = s[s.Length / 2];
                        s = s.Remove(s.Length / 2, 1);
                        break;
                    case 2:
                        ch = s[s.Length - 1];
                        s = s.Remove(s.Length - 1, 1);
                        break;
                }
                switch (phase2)
                {
                    case 0:
                        output = ch + output;
                        break;
                    case 1:
                        output = output + ch;
                        break;
                }
                phase1 = (phase1 + 1) % 3;
                phase2 = (phase2 + 1) % 2;
            }

               /* for (int i = output.Length - 1; i >= 0; i--)
            {
                if (output[i] == "\\")
                    output = output.Insert(i, "\\");
            }*/

            return output.Str;
        }
 /// <summary>
 /// Put complex types with string properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 'goodrequest', '', and null
 /// </param>
 public static void PutString(this IPrimitiveOperations operations, StringWrapper complexBody)
 {
     Task.Factory.StartNew(s => ((IPrimitiveOperations)s).PutStringAsync(complexBody), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Put complex types with string properties
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='complexBody'>
 /// Please put 'goodrequest', '', and null
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PutStringAsync(this IPrimitiveOperations operations, StringWrapper complexBody, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.PutStringWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false);
 }