本文整理汇总了C#中NSString.description方法的典型用法代码示例。如果您正苦于以下问题:C# NSString.description方法的具体用法?C# NSString.description怎么用?C# NSString.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSString
的用法示例。
在下文中一共展示了NSString.description方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoReadData
private void DoReadData(NSData data, NSString typeName)
{
switch (typeName.description())
{
// Note that this does not mean that the file is utf8, instead it means that the
// file is our default document type which means we need to deduce the encoding.
case "Plain Text, UTF8 Encoded":
case "HTML":
Boss boss = ObjectModel.Create("TextEditorPlugin");
var encoding = boss.Get<ITextEncoding>();
NSString str = encoding.Decode(data, out m_encoding);
m_text = NSMutableAttributedString.Alloc().initWithString(str).To<NSMutableAttributedString>();
if (m_encoding == Enums.NSMacOSRomanStringEncoding)
DoEncodingWarning();
// If an html file is being edited in Continuum then ensure that it is saved
// as plain text. (To save a document as html the user needs to use save as
// and explicitly select html).
setFileType(NSString.Create("Plain Text, UTF8 Encoded"));
break;
// These types are based on the file's extension so we can (more or less) trust them.
case "Rich Text Format (RTF)":
m_text = DoReadWrapped(data, Externs.NSRTFTextDocumentType);
break;
case "Word 97 Format (doc)":
m_text = DoReadWrapped(data, Externs.NSDocFormatTextDocumentType);
break;
case "Word 2007 Format (docx)":
m_text = DoReadWrapped(data, Externs.NSOfficeOpenXMLTextDocumentType);
break;
case "Open Document Text (odt)":
m_text = DoReadWrapped(data, Externs.NSOpenDocumentTextDocumentType);
break;
// Open as Binary
case "binary":
m_text = NSMutableAttributedString.Create(data.bytes().ToText());
m_binary = true;
m_encoding = Enums.NSUTF8StringEncoding;
break;
default:
Contract.Assert(false, "bad typeName: " + typeName.description());
break;
}
}
示例2: OnPathChanged
public void OnPathChanged()
{
if (Path != null || m_boss.Has<IDocumentExtension>())
Language = DoFindLanguage();
if (Path != null)
{
NSRect frame = WindowDatabase.GetFrame(Path);
if (frame != NSRect.Empty)
window().setFrame_display(frame, true); // note that Cocoa will ensure that windows with title bars are not moved off screen
if (m_watcher != null)
{
m_watcher.Dispose();
m_watcher = null;
}
if ((object) m_dir != null)
{
m_dir.release();
m_dir = null;
}
var complete = m_boss.Get<IAutoComplete>();
complete.OnPathChanged();
string dir = System.IO.Path.GetDirectoryName(Path);
m_dir = NSString.Create(dir).stringByResolvingSymlinksInPath().Retain();
m_watcher = new DirectoryWatcher(m_dir.description(), TimeSpan.FromMilliseconds(250));
m_watcher.Changed += this.DoDirChanged;
if (m_restorer != null)
m_restorer.SetPath(Path);
}
else
((DeclarationsPopup) m_decPopup.Value).Init(this);
}
示例3: dataOfType_error
// Used to write the document.
public NSData dataOfType_error(NSString typeName, IntPtr outError)
{
NSData data = null;
try
{
DoCheckForControlChars(m_controller.TextView.textStorage().string_());
NSMutableAttributedString astr = m_controller.TextView.textStorage().mutableCopy().To<NSMutableAttributedString>();
NSMutableString str = astr.mutableString();
astr.autorelease();
DoRestoreEndian(str);
switch (typeName.description())
{
case "Plain Text, UTF8 Encoded":
// This is more like the default plain text type: when loading a document that is not
// rtf or word or whatever this typename will be chosen via the plist. However the actual
// encoding is inferred from the contents of the file (or set via the Get Info panel).
data = str.dataUsingEncoding_allowLossyConversion(m_encoding, true);
break;
case "Plain Text, UTF16 Encoded":
// This case is only used when the user selects save as and then the utf16 encoding.
m_encoding = Enums.NSUTF16LittleEndianStringEncoding;
data = str.dataUsingEncoding_allowLossyConversion(m_encoding, true);
break;
case "HTML":
data = DoWriteWrapped(astr, Externs.NSHTMLTextDocumentType);
break;
case "Rich Text Format (RTF)":
data = DoWriteWrapped(astr, Externs.NSRTFTextDocumentType);
break;
case "Word 97 Format (doc)":
data = DoWriteWrapped(astr, Externs.NSDocFormatTextDocumentType);
break;
case "Word 2007 Format (docx)":
data = DoWriteWrapped(astr, Externs.NSOfficeOpenXMLTextDocumentType);
break;
case "Open Document Text (odt)":
data = DoWriteWrapped(astr, Externs.NSOpenDocumentTextDocumentType);
break;
default:
Contract.Assert(false, "bad typeName: " + typeName.description());
break;
}
}
catch (Exception e)
{
Log.WriteLine(TraceLevel.Error, "App", "couldn't save:");
Log.WriteLine(TraceLevel.Error, "App", "{0}", e);
NSMutableDictionary userInfo = NSMutableDictionary.Create();
userInfo.setObject_forKey(NSString.Create("Couldn't convert the document to NSData."), Externs.NSLocalizedDescriptionKey);
userInfo.setObject_forKey(NSString.Create(e.Message), Externs.NSLocalizedFailureReasonErrorKey);
NSObject error = NSError.errorWithDomain_code_userInfo(Externs.Cocoa3Domain, 1, userInfo);
Marshal.WriteIntPtr(outError, error);
}
return data;
}
示例4: Find
// Returns the (open) item which matches the specified path or null
// if no item was found.
public virtual TableItem Find(NSString path)
{
if (Paths.AreEqual(path.description(), Path))
return this;
return null;
}