コード例 #1
0
        public ReadOnlyCollection <GestureRecognitionResult> Recognize(StrokeCollection strokes)
        {
            //
            // due to possible exploits in the Tablet PC Gesture recognizer's Recognize method,
            // we demand unmanaged code.
            //
            SecurityHelper.DemandUnmanagedCode();

            return(RecognizeImpl(strokes));
        }
コード例 #2
0
        internal static void SafeLaunchBrowserDemandWhenUnsafe(Uri originatingUri, Uri destinationUri, bool fIsTopLevel)
        {
            LaunchResult launched = LaunchResult.NotLaunched;

            launched = SafeLaunchBrowserOnlyIfPossible(originatingUri, destinationUri, fIsTopLevel);
            if (launched == LaunchResult.NotLaunched)
            {
                SecurityHelper.DemandUnmanagedCode();
                UnsafeLaunchBrowser(destinationUri);
            }
        }
コード例 #3
0
ファイル: DataFormats.cs プロジェクト: wenzai007/dotnet462
        public static DataFormat GetDataFormat(string format)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            if (format == string.Empty)
            {
                throw new ArgumentException(SR.Get(SRID.DataObject_EmptyFormatNotAllowed));
            }

            // Ensures the predefined Win32 data formats into our format list.
            EnsurePredefined();

            // Lock the data format list to obtains the mutual-exclusion.
            lock (_formatListlock)
            {
                int formatId;
                int index;

                // It is much faster to do a case sensitive search here.  So do
                // the case sensitive compare first, then the expensive one.
                //
                for (int n = 0; n < _formatList.Count; n++)
                {
                    DataFormat formatItem;

                    formatItem = (DataFormat)_formatList[n];

                    if (formatItem.Name.Equals(format))
                    {
                        return(formatItem);
                    }
                }

                for (int n = 0; n < _formatList.Count; n++)
                {
                    DataFormat formatItem;

                    formatItem = (DataFormat)_formatList[n];

                    if (String.Compare(formatItem.Name, format, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(formatItem);
                    }
                }

                // In the most cases the default formats return earlier. If we got here
                // then this is an attempt to register a new format which is not ok in partial trust.
                SecurityHelper.DemandUnmanagedCode();
                // Reigster the this format string.
                formatId = UnsafeNativeMethods.RegisterClipboardFormat(format);

                if (formatId == 0)
                {
                    throw new System.ComponentModel.Win32Exception();
                }

                index = _formatList.Add(new DataFormat(format, formatId));

                return((DataFormat)_formatList[index]);
            }
        }